﻿// **************************************************
// dotTweet 1.0 - Twitter API Wrapper DLL
// Developed by Dennis Delimarsky. Copyright © 2009.
// **************************************************
// Project web site: http://dottweet.codeplex.com
// **************************************************
// Main.cs
// This class contains all the functions used to connect
// to Twitter and execute various API calls.
// **************************************************


//TODO: Twitter Lists API


using System;
using System.Collections;
using System.Xml;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Syndication;
using System.Net;
using System.IO;

namespace dotTweet
{
    public class dotTweet
    {
        #region Search

        ///<summary>
        ///Returns tweets that match a specified query.
        ///http://apiwiki.twitter.com/Twitter-Search-API-Method%3A-search
        ///</summary>

        public enum Search
        {
            String,
            FromUser,
            ReplyToUser,
            MentioningUser,
            ContainingHashtag,
            OriginatingFromApplication
        }

        /// <param name="searchType">The type of the search model.</param>
        /// <param name="searchString">The string to look for in the updates.</param>
        public static ArrayList SearchTweet(Search searchType, string searchString)
        {
            ArrayList searchResults = new ArrayList();
            KeyValuePair<KeyValuePair<string, string>, string> foundElement = new KeyValuePair<KeyValuePair<string, string>, string>();
            KeyValuePair<string, string> additionalElement = new KeyValuePair<string, string>();

            try
            {
                switch (searchType)
                {
                    case Search.String:
                        {
                            XmlReader feedReader = XmlReader.Create("http://search.twitter.com/search.atom?q=" + searchString);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);

                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case Search.FromUser:
                        {
                            XmlReader feedReader = XmlReader.Create("http://search.twitter.com/search.atom?q=from%3A" + searchString);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);

                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case Search.ReplyToUser:
                        {
                            XmlReader feedReader = XmlReader.Create("http://search.twitter.com/search.atom?q=to%3A" + searchString);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);

                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case Search.MentioningUser:
                        {
                            XmlReader feedReader = XmlReader.Create("http://search.twitter.com/search.atom?q=%40" + searchString);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);

                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case Search.ContainingHashtag:
                        {
                            XmlReader feedReader = XmlReader.Create("http://search.twitter.com/search.atom?q=%23" + searchString);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);

                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case Search.OriginatingFromApplication:
                        {
                            XmlReader feedReader = XmlReader.Create("http://search.twitter.com/search.atom?q=landing+source:" + searchString);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);

                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }

                }
                return searchResults;
            }
            catch
            {
                return null;
            }


        }
        #endregion

        #region Trends

        /// <summary>
        /// Returns the top ten topics that are currently trending on Twitter.
        /// http://apiwiki.twitter.com/Twitter-Search-API-Method%3A-trends
        /// </summary>

        public static ArrayList Trends()
        {
            try
            {
                ArrayList trendsList = new ArrayList();

                WebClient trendsClient = new WebClient();

                string trendsJSON = ASCIIEncoding.Default.GetString(trendsClient.DownloadData("http://search.twitter.com/trends.json"));

                int openBracket = 0;
                int closeBracket = 0;

                openBracket = trendsJSON.IndexOf('[');
                closeBracket = trendsJSON.IndexOf(']');

                string onlyTrends = trendsJSON.Substring(openBracket + 1, trendsJSON.Length - openBracket - (trendsJSON.Length - closeBracket) - 2);

                string[] splitJSON = onlyTrends.Split('}');

                foreach (string splitString in splitJSON)
                {
                    string name = "";
                    string url = "";
                    int nameLocation = splitString.IndexOf("name");
                    int urlLocation = splitString.IndexOf("url");
                    name = splitString.Substring(nameLocation + 7, splitString.Length - (splitString.Length - urlLocation) - nameLocation - 10);
                    url = splitString.Substring(urlLocation + 6, splitString.Length - urlLocation - 7);
                    url = url.Replace("\\/", "/");
                    KeyValuePair<string, string> valuePair = new KeyValuePair<string, string>(name, url);
                    trendsList.Add(valuePair);
                }

                return trendsList;
            }
            catch
            {
                return null;
            }

        }
        #endregion

        #region Trends/Current

        /// <summary>
        /// Returns the current top 10 trending topics on Twitter.
        /// http://apiwiki.twitter.com/Twitter-Search-API-Method%3A-trends-current
        /// </summary>
        public enum Hashtags
        {
            Accept,
            Ignore
        }
        /// <param name="hashtags">Choose whether to ignore or accept trends that contain hashtags.</param>
        public static ArrayList TrendsCurrent(Hashtags hashtags)
        {
            try
            {
                ArrayList trendsList = new ArrayList();
                WebClient trendsClient = new WebClient();

                if (hashtags == Hashtags.Accept)
                {

                    string trendsJSON = ASCIIEncoding.Default.GetString(trendsClient.DownloadData("http://search.twitter.com/trends/current.json"));

                    int openBracket = 0;
                    int closeBracket = 0;

                    openBracket = trendsJSON.IndexOf('[');
                    closeBracket = trendsJSON.IndexOf(']');

                    string onlyTrends = trendsJSON.Substring(openBracket + 1, trendsJSON.Length - openBracket - (trendsJSON.Length - closeBracket) - 2);

                    string[] splitJSON = onlyTrends.Split('}');

                    foreach (string splitString in splitJSON)
                    {
                        string query = "";
                        string name = "";
                        int nameLocation = splitString.IndexOf("query");
                        int urlLocation = splitString.IndexOf("name");
                        query = splitString.Substring(nameLocation + 8, splitString.Length - (splitString.Length - urlLocation) - nameLocation - 11);
                        name = splitString.Substring(urlLocation + 7, splitString.Length - urlLocation - 8);
                        name = name.Replace("\\/", "/");
                        KeyValuePair<string, string> valuePair = new KeyValuePair<string, string>(query, name);
                        trendsList.Add(valuePair);
                    }
                }
                else if (hashtags == Hashtags.Ignore)
                {
                    string trendsJSON = ASCIIEncoding.Default.GetString(trendsClient.DownloadData("http://search.twitter.com/trends/current.json?exclude=hashtags"));

                    int openBracket = 0;
                    int closeBracket = 0;

                    openBracket = trendsJSON.IndexOf('[');
                    closeBracket = trendsJSON.IndexOf(']');

                    string onlyTrends = trendsJSON.Substring(openBracket + 1, trendsJSON.Length - openBracket - (trendsJSON.Length - closeBracket) - 2);

                    string[] splitJSON = onlyTrends.Split('}');

                    foreach (string splitString in splitJSON)
                    {
                        string query = "";
                        string name = "";
                        int nameLocation = splitString.IndexOf("query");
                        int urlLocation = splitString.IndexOf("name");
                        query = splitString.Substring(nameLocation + 8, splitString.Length - (splitString.Length - urlLocation) - nameLocation - 11);
                        name = splitString.Substring(urlLocation + 7, splitString.Length - urlLocation - 8);
                        name = name.Replace("\\/", "/");
                        KeyValuePair<string, string> valuePair = new KeyValuePair<string, string>(query, name);
                        trendsList.Add(valuePair);
                    }
                }
                return trendsList;
            }
            catch
            {
                return null;
            }


        }
        #endregion

        #region Trends/Daily

        ///<summary>
        ///Returns the top 20 trending topics for each hour in a given day.
        ///http://apiwiki.twitter.com/Twitter-Search-API-Method%3A-trends-daily
        /// </summary>
        /// <param name="hashtags">Choose whether to ignore or accept trends that contain hashtags.</param>

        public static ArrayList TrendsDaily(Hashtags hashtags)
        {
            try
            {
                ArrayList trendsList = new ArrayList();
                WebClient trendsClient = new WebClient();

                if (hashtags == Hashtags.Accept)
                {

                    string trendsJSON = ASCIIEncoding.Default.GetString(trendsClient.DownloadData("http://search.twitter.com/trends/daily.json"));

                    int openBracket = 0;
                    int closeBracket = 0;

                    openBracket = trendsJSON.IndexOf('[');
                    closeBracket = trendsJSON.IndexOf(']');

                    string onlyTrends = trendsJSON.Substring(openBracket + 1, trendsJSON.Length - openBracket - (trendsJSON.Length - closeBracket) - 2);

                    string[] splitJSON = onlyTrends.Split('}');

                    foreach (string splitString in splitJSON)
                    {
                        string query = "";
                        string name = "";
                        int nameLocation = splitString.IndexOf("query");
                        int urlLocation = splitString.IndexOf("name");
                        query = splitString.Substring(nameLocation + 8, splitString.Length - (splitString.Length - urlLocation) - nameLocation - 11);
                        name = splitString.Substring(urlLocation + 7, splitString.Length - urlLocation - 8);
                        name = name.Replace("\\/", "/");
                        KeyValuePair<string, string> valuePair = new KeyValuePair<string, string>(query, name);
                        trendsList.Add(valuePair);
                    }
                }
                else if (hashtags == Hashtags.Ignore)
                {
                    string trendsJSON = ASCIIEncoding.Default.GetString(trendsClient.DownloadData("http://search.twitter.com/trends/daily.json?exclude=hashtags"));

                    int openBracket = 0;
                    int closeBracket = 0;

                    openBracket = trendsJSON.IndexOf('[');
                    closeBracket = trendsJSON.IndexOf(']');

                    string onlyTrends = trendsJSON.Substring(openBracket + 1, trendsJSON.Length - openBracket - (trendsJSON.Length - closeBracket) - 2);

                    string[] splitJSON = onlyTrends.Split('}');

                    foreach (string splitString in splitJSON)
                    {
                        string query = "";
                        string name = "";
                        int nameLocation = splitString.IndexOf("query");
                        int urlLocation = splitString.IndexOf("name");
                        query = splitString.Substring(nameLocation + 8, splitString.Length - (splitString.Length - urlLocation) - nameLocation - 11);
                        name = splitString.Substring(urlLocation + 7, splitString.Length - urlLocation - 8);
                        name = name.Replace("\\/", "/");
                        KeyValuePair<string, string> valuePair = new KeyValuePair<string, string>(query, name);
                        trendsList.Add(valuePair);
                    }
                }
                return trendsList;
            }
            catch
            {
                return null;
            }
        }

        /// <param name="date">The date for the update set. Should be in the YYYY-MM-DD format for correct processing.</param>
        public static ArrayList TrendsDaily(string date)
        {
            try
            {
                ArrayList trendsList = new ArrayList();
                WebClient trendsClient = new WebClient();

                string trendsJSON = ASCIIEncoding.Default.GetString(trendsClient.DownloadData("http://search.twitter.com/trends/daily.json?date=" + date));

                int openBracket = 0;
                int closeBracket = 0;

                openBracket = trendsJSON.IndexOf('[');
                closeBracket = trendsJSON.IndexOf(']');

                string onlyTrends = trendsJSON.Substring(openBracket + 1, trendsJSON.Length - openBracket - (trendsJSON.Length - closeBracket) - 2);

                string[] splitJSON = onlyTrends.Split('}');

                foreach (string splitString in splitJSON)
                {
                    string query = "";
                    string name = "";
                    int nameLocation = splitString.IndexOf("query");
                    int urlLocation = splitString.IndexOf("name");
                    query = splitString.Substring(nameLocation + 8, splitString.Length - (splitString.Length - urlLocation) - nameLocation - 11);
                    name = splitString.Substring(urlLocation + 7, splitString.Length - urlLocation - 8);
                    name = name.Replace("\\/", "/");
                    KeyValuePair<string, string> valuePair = new KeyValuePair<string, string>(query, name);
                    trendsList.Add(valuePair);
                }

                return trendsList;
            }
            catch
            {
                return null;
            }
        }

        #endregion

        #region Trends/Weekly

        ///<summary>
        ///Returns the top 30 trending topics for each day in a given week.
        ///http://apiwiki.twitter.com/Twitter-Search-API-Method%3A-trends-weekly
        /// </summary>
        /// <param name="hashtags">Choose whether to ignore or accept trends that contain hashtags.</param>

        public static ArrayList TrendsWeekly(Hashtags hashtags)
        {
            try
            {
                ArrayList trendsList = new ArrayList();
                WebClient trendsClient = new WebClient();

                if (hashtags == Hashtags.Accept)
                {

                    string trendsJSON = ASCIIEncoding.Default.GetString(trendsClient.DownloadData("http://search.twitter.com/trends/weekly.json"));

                    int openBracket = 0;
                    int closeBracket = 0;

                    openBracket = trendsJSON.IndexOf('[');
                    closeBracket = trendsJSON.IndexOf(']');

                    string onlyTrends = trendsJSON.Substring(openBracket + 1, trendsJSON.Length - openBracket - (trendsJSON.Length - closeBracket) - 2);

                    string[] splitJSON = onlyTrends.Split('}');

                    foreach (string splitString in splitJSON)
                    {
                        string query = "";
                        string name = "";
                        int nameLocation = splitString.IndexOf("query");
                        int urlLocation = splitString.IndexOf("name");
                        query = splitString.Substring(nameLocation + 8, splitString.Length - (splitString.Length - urlLocation) - nameLocation - 11);
                        name = splitString.Substring(urlLocation + 7, splitString.Length - urlLocation - 8);
                        name = name.Replace("\\/", "/");
                        KeyValuePair<string, string> valuePair = new KeyValuePair<string, string>(query, name);
                        trendsList.Add(valuePair);
                    }
                }
                else if (hashtags == Hashtags.Ignore)
                {
                    string trendsJSON = ASCIIEncoding.Default.GetString(trendsClient.DownloadData("http://search.twitter.com/trends/weekly.json?exclude=hashtags"));

                    int openBracket = 0;
                    int closeBracket = 0;

                    openBracket = trendsJSON.IndexOf('[');
                    closeBracket = trendsJSON.IndexOf(']');

                    string onlyTrends = trendsJSON.Substring(openBracket + 1, trendsJSON.Length - openBracket - (trendsJSON.Length - closeBracket) - 2);

                    string[] splitJSON = onlyTrends.Split('}');

                    foreach (string splitString in splitJSON)
                    {
                        string query = "";
                        string name = "";
                        int nameLocation = splitString.IndexOf("query");
                        int urlLocation = splitString.IndexOf("name");
                        query = splitString.Substring(nameLocation + 8, splitString.Length - (splitString.Length - urlLocation) - nameLocation - 11);
                        name = splitString.Substring(urlLocation + 7, splitString.Length - urlLocation - 8);
                        name = name.Replace("\\/", "/");
                        KeyValuePair<string, string> valuePair = new KeyValuePair<string, string>(query, name);
                        trendsList.Add(valuePair);
                    }
                }
                return trendsList;
            }
            catch
            {
                return null;
            }
        }

        /// <param name="date">The date for the update set. Should be in the YYYY-MM-DD format for correct processing.</param>
        public static ArrayList TrendsWeekly(string date)
        {
            try
            {
                ArrayList trendsList = new ArrayList();
                WebClient trendsClient = new WebClient();

                string trendsJSON = ASCIIEncoding.Default.GetString(trendsClient.DownloadData("http://search.twitter.com/trends/weekly.json?date=" + date));

                int openBracket = 0;
                int closeBracket = 0;

                openBracket = trendsJSON.IndexOf('[');
                closeBracket = trendsJSON.IndexOf(']');

                string onlyTrends = trendsJSON.Substring(openBracket + 1, trendsJSON.Length - openBracket - (trendsJSON.Length - closeBracket) - 2);

                string[] splitJSON = onlyTrends.Split('}');

                foreach (string splitString in splitJSON)
                {
                    string query = "";
                    string name = "";
                    int nameLocation = splitString.IndexOf("query");
                    int urlLocation = splitString.IndexOf("name");
                    query = splitString.Substring(nameLocation + 8, splitString.Length - (splitString.Length - urlLocation) - nameLocation - 11);
                    name = splitString.Substring(urlLocation + 7, splitString.Length - urlLocation - 8);
                    name = name.Replace("\\/", "/");
                    KeyValuePair<string, string> valuePair = new KeyValuePair<string, string>(query, name);
                    trendsList.Add(valuePair);
                }

                return trendsList;
            }
            catch
            {
                return null;
            }
        }

        #endregion

        #region Statuses/Public Timeline
        /// <summary>
        /// Returns the 20 most recent statuses from non-protected users who have set a custom user icon. 
        /// The public timeline is cached for 60 seconds so requesting it more often than that is a waste
        /// of resources.
        /// http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-public_timeline
        /// </summary>
        public static ArrayList Statuses_PublicTimeline()
        {
            try
            {
                ArrayList searchResults = new ArrayList();
                KeyValuePair<KeyValuePair<string, string>, string> foundElement = new KeyValuePair<KeyValuePair<string, string>, string>();
                KeyValuePair<string, string> additionalElement = new KeyValuePair<string, string>();

                XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/public_timeline.atom");
                SyndicationFeed feed = SyndicationFeed.Load(feedReader);

                foreach (var feedItem in feed.Items)
                {
                    additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                    foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                    searchResults.Add(foundElement);
                }

                feedReader.Close();

                return searchResults;
            }
            catch
            {
                return null;
            }
        }
        #endregion

        #region Statuses/Friends Timeline

        public enum Optional
        {
            None,
            SinceID,
            MaxID,
            Count,
            Page
        }
        /// <summary>
        /// Returns the 20 most recent statuses posted by the authenticating user and that 
        /// user's friends. This is the equivalent of /timeline/home on the Web.
        /// http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-friends_timeline
        /// </summary>
        /// <param name="password">Twitter account password.</param>
        /// <param name="username">Twitter account username.</param>
        /// <param name="optional">The type of optional parameter to apply to the search.</param>
        /// <param name="optValue">The value of the optional parameter applied to the search. For Optional.None the field can hold any value. Required.</param>
        public static ArrayList Statuses_FriendsTimeline(string username, string password, Optional optional, string optValue)
        {
            try
            {

                ArrayList searchResults = new ArrayList();
                KeyValuePair<KeyValuePair<string, string>, string> foundElement = new KeyValuePair<KeyValuePair<string, string>, string>();
                KeyValuePair<string, string> additionalElement = new KeyValuePair<string, string>();

                XmlUrlResolver xmlResolver = new XmlUrlResolver();
                xmlResolver.Credentials = new NetworkCredential(username, password);

                XmlReaderSettings xmlSettings = new XmlReaderSettings();
                xmlSettings.XmlResolver = xmlResolver;

                switch (optional)
                {
                    case Optional.None:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/friends_timeline.atom", xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case Optional.SinceID:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/friends_timeline.atom?since_id=" + optValue, xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case Optional.MaxID:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/friends_timeline.atom?max_id=" + optValue, xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case Optional.Count:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/friends_timeline.atom?count=" + optValue, xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case Optional.Page:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/friends_timeline.atom?page=" + optValue, xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                }
                return searchResults;
            }
            catch
            {
                return null;
            }
        }
        #endregion

        #region Statuses/Home Timeline
        /// <summary>
        /// Returns the 20 most recent statuses, including retweets, posted by the authenticating user
        /// and that user's friends. This is the equivalent of /timeline/home on the Web.
        /// Usage note: This home_timeline is identical to statuses/friends_timeline except
        /// it also contains retweets, which statuses/friends_timeline does not (for backwards compatibility reasons).
        /// In a future version of the API, statuses/friends_timeline will go away and be replaced by home_timeline.
        /// </summary>
        /// <param name="username">Twitter account username</param>
        /// <param name="password">Twitter account password</param>
        /// <param name="optional">The type of optional parameter to apply to the search.</param>
        /// <param name="optValue">The value of the optional search parameter. Use string.Empty for None.</param>
        /// <returns></returns>
        public static ArrayList Statuses_HomeTimeline(string username, string password, Optional optional, string optValue)
        {
            try
            {
                ArrayList searchResults = new ArrayList();
                KeyValuePair<KeyValuePair<string, string>, string> foundElement = new KeyValuePair<KeyValuePair<string, string>, string>();
                KeyValuePair<string, string> additionalElement = new KeyValuePair<string, string>();

                XmlUrlResolver xmlResolver = new XmlUrlResolver();
                xmlResolver.Credentials = new NetworkCredential(username, password);

                XmlReaderSettings xmlSettings = new XmlReaderSettings();
                xmlSettings.XmlResolver = xmlResolver;

                switch (optional)
                {
                    case Optional.None:
                        {
                            XmlReader feedReader = XmlReader.Create("http://api.twitter.com/1/statuses/home_timeline.atom", xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case Optional.SinceID:
                        {
                            XmlReader feedReader = XmlReader.Create("http://api.twitter.com/1/statuses/home_timeline.atom?since_id=" + optValue, xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case Optional.MaxID:
                        {
                            XmlReader feedReader = XmlReader.Create("http://api.twitter.com/1/statuses/home_timeline.atom?max_id=" + optValue, xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case Optional.Count:
                        {
                            XmlReader feedReader = XmlReader.Create("http://api.twitter.com/1/statuses/home_timeline.atom?count=" + optValue, xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case Optional.Page:
                        {
                            XmlReader feedReader = XmlReader.Create("http://api.twitter.com/1/statuses/home_timeline.atom?page=" + optValue, xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                }
                return searchResults;
            }
            catch
            {
                return null;
            }
        }
#endregion

        #region Statuses/User Timeline
        public enum TimelineParameter
        {
            ID,
            UserID,
            ScreenName,
            SinceID,
            MaxID,
            Count,
            Page
        }

        /// <summary>
        /// Returns the 20 most recent statuses posted from the authenticating user. 
        /// It's also possible to request another user's timeline via the id parameter.
        /// This is the equivalent of the Web /user page for your own user, 
        /// or the profile page for a third party.
        /// http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-user_timeline
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        /// <returns></returns>
        public static ArrayList Stauses_UserTimeline(string username, string password)
        {
            try
            {
                ArrayList searchResults = new ArrayList();
                KeyValuePair<KeyValuePair<string, string>, string> foundElement = new KeyValuePair<KeyValuePair<string, string>, string>();
                KeyValuePair<string, string> additionalElement = new KeyValuePair<string, string>();

                XmlUrlResolver xmlResolver = new XmlUrlResolver();
                xmlResolver.Credentials = new NetworkCredential(username, password);

                XmlReaderSettings xmlSettings = new XmlReaderSettings();
                xmlSettings.XmlResolver = xmlResolver;

                XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/user_timeline.atom", xmlSettings);
                SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                foreach (var feedItem in feed.Items)
                {
                    additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                    foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                    searchResults.Add(foundElement);
                }

                feedReader.Close();
                return searchResults;
            }
            catch
            {
                return null;
            }
        }

        /// <param name="tParam">[Public Updates] Additional update search parameter.</param>
        /// <param name="paramValue">[Public Updates] Parameter value.</param>
        public static ArrayList Stauses_UserTimeline(TimelineParameter tParam, string paramValue)
        {
            try
            {
                ArrayList searchResults = new ArrayList();
                KeyValuePair<KeyValuePair<string, string>, string> foundElement = new KeyValuePair<KeyValuePair<string, string>, string>();
                KeyValuePair<string, string> additionalElement = new KeyValuePair<string, string>();

                switch (tParam)
                {
                    case (TimelineParameter.ID):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/user_timeline/" + paramValue + ".atom");
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case (TimelineParameter.UserID):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/user_timeline.atom?user_id=" + paramValue);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case (TimelineParameter.ScreenName):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/user_timeline.atom?screen_name=" + paramValue);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case (TimelineParameter.SinceID):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/user_timeline.atom?since_id=" + paramValue);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case (TimelineParameter.MaxID):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/user_timeline.atom?max_id=" + paramValue);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case (TimelineParameter.Count):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/user_timeline.atom?count=" + paramValue);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case (TimelineParameter.Page):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/user_timeline.atom?page=" + paramValue);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].Name.ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }

                }
                return searchResults;
            }
            catch
            {
                return null;
            }
        }

        /// <param name="tParam">[Protected Updates] Additional update search parameter.</param>
        /// <param name="paramValue">[Protected Updates] Parameter value.</param>
        ///<param name="username">[Protected Updates] Twitter account username.</param>
        /// <param name="password">[Protected Updates] Twitter account password.</param>
        public static ArrayList Stauses_UserTimeline(TimelineParameter tParam, string paramValue, string username, string password)
        {
            try
            {
                ArrayList searchResults = new ArrayList();
                KeyValuePair<KeyValuePair<string, string>, string> foundElement = new KeyValuePair<KeyValuePair<string, string>, string>();
                KeyValuePair<string, string> additionalElement = new KeyValuePair<string, string>();

                XmlUrlResolver xmlResolver = new XmlUrlResolver();
                xmlResolver.Credentials = new NetworkCredential(username, password);

                XmlReaderSettings xmlSettings = new XmlReaderSettings();
                xmlSettings.XmlResolver = xmlResolver;

                switch (tParam)
                {
                    case (TimelineParameter.ID):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/user_timeline/" + paramValue + ".atom", xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case (TimelineParameter.UserID):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/user_timeline.atom?user_id=" + paramValue, xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case (TimelineParameter.ScreenName):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/user_timeline.atom?screen_name=" + paramValue, xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case (TimelineParameter.SinceID):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/user_timeline.atom?since_id=" + paramValue, xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case (TimelineParameter.MaxID):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/user_timeline.atom?max_id=" + paramValue, xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case (TimelineParameter.Count):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/user_timeline.atom?count=" + paramValue, xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case (TimelineParameter.Page):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/user_timeline.atom?page=" + paramValue, xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }

                }
                return searchResults;
            }
            catch
            {
                return null;
            }
        }
        #endregion

        #region Statuses/Mentions

        ///<summary>
        ///Returns the 20 most recent mentions (status containing @username) for the authenticating user.
        ///http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses-mentions
        ///</summary>
        ///<param name="username">Twitter account username.</param>
        ///<param name="password">Twitter account password.</param>
        ///<param name="optional">The type of optional parameter to apply to the search.</param>
        ///<param name="optValue">The value of the optional parameter applied to the search. For Optional.None the field can hold any value. Required.</param>
        public static ArrayList Statuses_Mentions(string username, string password, Optional optional, string optValue)
        {
            try
            {
                ArrayList searchResults = new ArrayList();
                KeyValuePair<KeyValuePair<string, string>, string> foundElement = new KeyValuePair<KeyValuePair<string, string>, string>();
                KeyValuePair<string, string> additionalElement = new KeyValuePair<string, string>();

                XmlUrlResolver xmlResolver = new XmlUrlResolver();
                xmlResolver.Credentials = new NetworkCredential(username, password);

                XmlReaderSettings xmlSettings = new XmlReaderSettings();
                xmlSettings.XmlResolver = xmlResolver;

                switch (optional)
                {
                    case (Optional.None):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/mentions.atom", xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case (Optional.SinceID):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/mentions.atom?since_id=" + optValue, xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case (Optional.MaxID):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/mentions.atom?max_id=" + optValue, xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case (Optional.Count):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/mentions.atom?count=" + optValue, xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                    case (Optional.Page):
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/mentions.atom?page=" + optValue, xmlSettings);
                            SyndicationFeed feed = SyndicationFeed.Load(feedReader);


                            foreach (var feedItem in feed.Items)
                            {
                                additionalElement = new KeyValuePair<string, string>(feedItem.Id.ToString(), feedItem.Authors[0].ToString());
                                foundElement = new KeyValuePair<KeyValuePair<string, string>, string>(additionalElement, feedItem.Title.Text);
                                searchResults.Add(foundElement);
                            }

                            feedReader.Close();
                            break;
                        }
                }
                return searchResults;
            }
            catch
            {
                return null;
            }
        }
        #endregion

        #region Statuses/Show

        /// <summary>
        /// Returns a single status, specified by the id parameter below.  The status's author will be returned inline.
        /// http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses%C2%A0show
        /// </summary>
        /// <param name="id">Twitter user ID.</param>
        public static ArrayList Statuses_Show(string id)
        {
            try
            {
                ArrayList searchResults = new ArrayList();
                KeyValuePair<string, string> foundElement = new KeyValuePair<string, string>();

                XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/show/" + id + ".xml");
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(feedReader);

                foundElement = new KeyValuePair<string, string>(xmlDoc.SelectSingleNode("/status/user/name").InnerText, xmlDoc.SelectSingleNode("/status/text").InnerText);
                searchResults.Add(foundElement);

                feedReader.Close();

                return searchResults;
            }
            catch
            {
                return null;
            }
        }
        #endregion

        #region Statuses/Update

        public enum StatusType
        {
            Individual,
            InReply
        }
        /// <summary>
        /// Updates the authenticating user's status.  Requires the status parameter specified below. 
        /// Request must be a POST.  
        /// A status update with text identical to the authenticating user's current status will be 
        /// ignored to prevent duplicates.
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        /// <param name="status">The status that will be published (@username required if the status is in reply to someone).</param>
        /// <param name="statusType">The type of the status update.</param>
        /// <param name="reply_id">The status ID the current status is in reply.</param>
        public static string SetStatus(string username, string password, string status, StatusType statusType, string reply_id)
        {
            try
            {
                string responseToReturn;

                string userTo64 = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password));

                byte[] statusBytes = System.Text.Encoding.ASCII.GetBytes("status=" + status);

                if (statusType == StatusType.Individual)
                {
                    HttpWebRequest updateRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/statuses/update.xml");
                    updateRequest.Method = "POST";
                    updateRequest.ServicePoint.Expect100Continue = false;
                    updateRequest.Headers.Add("Authorization", "Basic " + userTo64);
                    updateRequest.ContentType = "application/x-www-form-urlencoded";
                    updateRequest.ContentLength = statusBytes.Length;

                    Stream requestStream = updateRequest.GetRequestStream();
                    requestStream.Write(statusBytes, 0, statusBytes.Length);
                    requestStream.Close();

                    HttpWebResponse response;
                    response = (HttpWebResponse)updateRequest.GetResponse();

                    StreamReader responseStream = new StreamReader(response.GetResponseStream());

                    responseToReturn = responseStream.ReadToEnd();
                }
                else
                {
                    HttpWebRequest updateRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/statuses/update.xml?in_reply_to_status_id=" + reply_id);
                    updateRequest.Method = "POST";
                    updateRequest.ServicePoint.Expect100Continue = false;
                    updateRequest.Headers.Add("Authorization", "Basic " + userTo64);
                    updateRequest.ContentType = "application/x-www-form-urlencoded";
                    updateRequest.ContentLength = statusBytes.Length;

                    Stream requestStream = updateRequest.GetRequestStream();
                    requestStream.Write(statusBytes, 0, statusBytes.Length);
                    requestStream.Close();

                    HttpWebResponse response;
                    response = (HttpWebResponse)updateRequest.GetResponse();

                    StreamReader responseStream = new StreamReader(response.GetResponseStream());

                    responseToReturn = responseStream.ReadToEnd();
                }

                return responseToReturn;

            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }

        #endregion

        #region Statuses / Destroy

        /// <summary>
        /// Destroys the status specified by the required ID parameter. 
        /// The authenticating user must be the author of the specified status.
        /// http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses%C2%A0destroy
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        /// <param name="id">Twitter status ID.</param>
        public static string Statuses_Destroy(string username, string password, string id)
        {
            try
            {
                WebRequest request = HttpWebRequest.Create("http://twitter.com/statuses/destroy/" + id + ".xml");
                request.Method = "DELETE";
                request.ContentLength = 0;
                request.Credentials = new NetworkCredential(username, password);

                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                StreamReader responseStream = new StreamReader(response.GetResponseStream());

                string responseString = responseStream.ReadToEnd();

                return responseString;
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
        #endregion

        #region Users / Show

        public enum SearchType
        {
            ByID,
            ByUserID,
            ByScreenName
        }

        /// <summary>
        /// Returns extended information of a given user, specified by ID or screen name 
        /// as per the required id parameter.  The author's most recent status will be returned inline.
        /// http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-users%C2%A0show
        /// </summary>
        /// <param name="searchType">The type of the search that will be performed.</param>
        /// <param name="search">The user to search.</param>
        public static User Users_Show(SearchType searchType, string search)
        {
            try
            {
                User userQuery = new User();

                switch (searchType)
                {
                    case SearchType.ByID:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/users/show/" + search + ".xml");
                            XmlDocument xmlDoc = new XmlDocument();
                            xmlDoc.Load(feedReader);

                            userQuery.ID = xmlDoc.SelectSingleNode("/user/id") != null ? xmlDoc.SelectSingleNode("/user/id").InnerText : string.Empty;
                            userQuery.Name = xmlDoc.SelectSingleNode("/user/name") != null ? xmlDoc.SelectSingleNode("/user/name").InnerText : string.Empty;
                            userQuery.ScreenName = xmlDoc.SelectSingleNode("/user/screen_name") != null ? xmlDoc.SelectSingleNode("/user/screen_name").InnerText : string.Empty;
                            userQuery.Location = xmlDoc.SelectSingleNode("/user/location") != null ? xmlDoc.SelectSingleNode("/user/location").InnerText : string.Empty;
                            userQuery.Description = xmlDoc.SelectSingleNode("/user/description") != null ? xmlDoc.SelectSingleNode("/user/description").InnerText : string.Empty;
                            userQuery.ProfileImageURL = xmlDoc.SelectSingleNode("/user/profile_image_url") != null ? xmlDoc.SelectSingleNode("/user/profile_image_url").InnerText : string.Empty;
                            userQuery.URL = xmlDoc.SelectSingleNode("/user/url") != null ? xmlDoc.SelectSingleNode("/user/url").InnerText : string.Empty;
                            userQuery.Protected = xmlDoc.SelectSingleNode("/user/protected") != null ? xmlDoc.SelectSingleNode("/user/protected").InnerText : string.Empty;
                            userQuery.Followers = xmlDoc.SelectSingleNode("/user/followers_count") != null ? xmlDoc.SelectSingleNode("/user/followers_count").InnerText : string.Empty;
                            userQuery.ProfileBackgroundColor = xmlDoc.SelectSingleNode("/user/profile_background_color") != null ? xmlDoc.SelectSingleNode("/user/profile_background_color").InnerText : string.Empty;
                            userQuery.ProfileTextColor = xmlDoc.SelectSingleNode("/user/profile_text_color") != null ? xmlDoc.SelectSingleNode("/user/profile_text_color").InnerText : string.Empty;
                            userQuery.ProfileLinkColor = xmlDoc.SelectSingleNode("/user/profile_link_color") != null ? xmlDoc.SelectSingleNode("/user/profile_link_color").InnerText : string.Empty;
                            userQuery.ProfileSidebarFillColor = xmlDoc.SelectSingleNode("/user/profile_sidebar_fill_color") != null ? xmlDoc.SelectSingleNode("/user/profile_sidebar_fill_color").InnerText : string.Empty;
                            userQuery.ProfileSidebarBorderColor = xmlDoc.SelectSingleNode("/user/profile_sidebar_border_color") != null ? xmlDoc.SelectSingleNode("/user/profile_sidebar_border_color").InnerText : string.Empty;
                            userQuery.FriendsCount = xmlDoc.SelectSingleNode("/user/friends_count") != null ? xmlDoc.SelectSingleNode("/user/friends_count").InnerText : string.Empty;
                            userQuery.UtcOffset = xmlDoc.SelectSingleNode("/user/utc_offset") != null ? xmlDoc.SelectSingleNode("/user/utc_offset").InnerText : string.Empty;
                            userQuery.TimeZone = xmlDoc.SelectSingleNode("/user/time_zone") != null ? xmlDoc.SelectSingleNode("/user/time_zone").InnerText : string.Empty;
                            userQuery.ProfileBackgroundImageUrl = xmlDoc.SelectSingleNode("/user/profile_background_image_url") != null ? xmlDoc.SelectSingleNode("/user/profile_background_image_url").InnerText : string.Empty;
                            userQuery.ProfileBackgroundTile = xmlDoc.SelectSingleNode("/user/profile_background_tile") != null ? xmlDoc.SelectSingleNode("/user/profile_background_tile").InnerText : string.Empty;
                            userQuery.StatusesCount = xmlDoc.SelectSingleNode("/user/statuses_count") != null ? xmlDoc.SelectSingleNode("/user/statuses_count").InnerText : string.Empty;
                            userQuery.Notifications = xmlDoc.SelectSingleNode("/user/notifications") != null ? xmlDoc.SelectSingleNode("/user/notifications").InnerText : string.Empty;
                            userQuery.Following = xmlDoc.SelectSingleNode("/user/following") != null ? xmlDoc.SelectSingleNode("/user/following").InnerText : string.Empty;
                            userQuery.Verified = xmlDoc.SelectSingleNode("/user/verified") != null ? xmlDoc.SelectSingleNode("/user/verified").InnerText : string.Empty;
                            userQuery.StatusCreatedAt = xmlDoc.SelectSingleNode("/user/status/created_at") != null ? xmlDoc.SelectSingleNode("/user/status/created_at").InnerText : string.Empty;
                            userQuery.StatusID = xmlDoc.SelectSingleNode("/user/status/id") != null ? xmlDoc.SelectSingleNode("/user/status/id").InnerText : string.Empty;
                            userQuery.StatusText = xmlDoc.SelectSingleNode("/user/status/text") != null ? xmlDoc.SelectSingleNode("/user/status/text").InnerText : string.Empty;
                            userQuery.StatusSource = xmlDoc.SelectSingleNode("/user/status/source") != null ? xmlDoc.SelectSingleNode("/user/status/source").InnerText : string.Empty;
                            userQuery.StatusTruncated = xmlDoc.SelectSingleNode("/user/status/truncated") != null ? xmlDoc.SelectSingleNode("/user/status/truncated").InnerText : string.Empty;
                            userQuery.StatusInReplyToStatusID = xmlDoc.SelectSingleNode("/user/status/in_reply_to_status_id") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_status_id").InnerText : string.Empty;
                            userQuery.StatusInReplyToUserID = xmlDoc.SelectSingleNode("/user/status/in_reply_to_user_id") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_user_id").InnerText : string.Empty;
                            userQuery.StatusFavorited = xmlDoc.SelectSingleNode("/user/status/favorited") != null ? xmlDoc.SelectSingleNode("/user/status/favorited").InnerText : string.Empty;
                            userQuery.StatusInReplyToScreenName = xmlDoc.SelectSingleNode("/user/status/in_reply_to_screen_name") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_screen_name").InnerText : string.Empty;

                            break;
                        }
                    case SearchType.ByScreenName:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/users/show.xml?screen_name=" + search);
                            XmlDocument xmlDoc = new XmlDocument();
                            xmlDoc.Load(feedReader);

                            userQuery.ID = xmlDoc.SelectSingleNode("/user/id") != null ? xmlDoc.SelectSingleNode("/user/id").InnerText : string.Empty;
                            userQuery.Name = xmlDoc.SelectSingleNode("/user/name") != null ? xmlDoc.SelectSingleNode("/user/name").InnerText : string.Empty;
                            userQuery.ScreenName = xmlDoc.SelectSingleNode("/user/screen_name") != null ? xmlDoc.SelectSingleNode("/user/screen_name").InnerText : string.Empty;
                            userQuery.Location = xmlDoc.SelectSingleNode("/user/location") != null ? xmlDoc.SelectSingleNode("/user/location").InnerText : string.Empty;
                            userQuery.Description = xmlDoc.SelectSingleNode("/user/description") != null ? xmlDoc.SelectSingleNode("/user/description").InnerText : string.Empty;
                            userQuery.ProfileImageURL = xmlDoc.SelectSingleNode("/user/profile_image_url") != null ? xmlDoc.SelectSingleNode("/user/profile_image_url").InnerText : string.Empty;
                            userQuery.URL = xmlDoc.SelectSingleNode("/user/url") != null ? xmlDoc.SelectSingleNode("/user/url").InnerText : string.Empty;
                            userQuery.Protected = xmlDoc.SelectSingleNode("/user/protected") != null ? xmlDoc.SelectSingleNode("/user/protected").InnerText : string.Empty;
                            userQuery.Followers = xmlDoc.SelectSingleNode("/user/followers_count") != null ? xmlDoc.SelectSingleNode("/user/followers_count").InnerText : string.Empty;
                            userQuery.ProfileBackgroundColor = xmlDoc.SelectSingleNode("/user/profile_background_color") != null ? xmlDoc.SelectSingleNode("/user/profile_background_color").InnerText : string.Empty;
                            userQuery.ProfileTextColor = xmlDoc.SelectSingleNode("/user/profile_text_color") != null ? xmlDoc.SelectSingleNode("/user/profile_text_color").InnerText : string.Empty;
                            userQuery.ProfileLinkColor = xmlDoc.SelectSingleNode("/user/profile_link_color") != null ? xmlDoc.SelectSingleNode("/user/profile_link_color").InnerText : string.Empty;
                            userQuery.ProfileSidebarFillColor = xmlDoc.SelectSingleNode("/user/profile_sidebar_fill_color") != null ? xmlDoc.SelectSingleNode("/user/profile_sidebar_fill_color").InnerText : string.Empty;
                            userQuery.ProfileSidebarBorderColor = xmlDoc.SelectSingleNode("/user/profile_sidebar_border_color") != null ? xmlDoc.SelectSingleNode("/user/profile_sidebar_border_color").InnerText : string.Empty;
                            userQuery.FriendsCount = xmlDoc.SelectSingleNode("/user/friends_count") != null ? xmlDoc.SelectSingleNode("/user/friends_count").InnerText : string.Empty;
                            userQuery.UtcOffset = xmlDoc.SelectSingleNode("/user/utc_offset") != null ? xmlDoc.SelectSingleNode("/user/utc_offset").InnerText : string.Empty;
                            userQuery.TimeZone = xmlDoc.SelectSingleNode("/user/time_zone") != null ? xmlDoc.SelectSingleNode("/user/time_zone").InnerText : string.Empty;
                            userQuery.ProfileBackgroundImageUrl = xmlDoc.SelectSingleNode("/user/profile_background_image_url") != null ? xmlDoc.SelectSingleNode("/user/profile_background_image_url").InnerText : string.Empty;
                            userQuery.ProfileBackgroundTile = xmlDoc.SelectSingleNode("/user/profile_background_tile") != null ? xmlDoc.SelectSingleNode("/user/profile_background_tile").InnerText : string.Empty;
                            userQuery.StatusesCount = xmlDoc.SelectSingleNode("/user/statuses_count") != null ? xmlDoc.SelectSingleNode("/user/statuses_count").InnerText : string.Empty;
                            userQuery.Notifications = xmlDoc.SelectSingleNode("/user/notifications") != null ? xmlDoc.SelectSingleNode("/user/notifications").InnerText : string.Empty;
                            userQuery.Following = xmlDoc.SelectSingleNode("/user/following") != null ? xmlDoc.SelectSingleNode("/user/following").InnerText : string.Empty;
                            userQuery.Verified = xmlDoc.SelectSingleNode("/user/verified") != null ? xmlDoc.SelectSingleNode("/user/verified").InnerText : string.Empty;
                            userQuery.StatusCreatedAt = xmlDoc.SelectSingleNode("/user/status/created_at") != null ? xmlDoc.SelectSingleNode("/user/status/created_at").InnerText : string.Empty;
                            userQuery.StatusID = xmlDoc.SelectSingleNode("/user/status/id") != null ? xmlDoc.SelectSingleNode("/user/status/id").InnerText : string.Empty;
                            userQuery.StatusText = xmlDoc.SelectSingleNode("/user/status/text") != null ? xmlDoc.SelectSingleNode("/user/status/text").InnerText : string.Empty;
                            userQuery.StatusSource = xmlDoc.SelectSingleNode("/user/status/source") != null ? xmlDoc.SelectSingleNode("/user/status/source").InnerText : string.Empty;
                            userQuery.StatusTruncated = xmlDoc.SelectSingleNode("/user/status/truncated") != null ? xmlDoc.SelectSingleNode("/user/status/truncated").InnerText : string.Empty;
                            userQuery.StatusInReplyToStatusID = xmlDoc.SelectSingleNode("/user/status/in_reply_to_status_id") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_status_id").InnerText : string.Empty;
                            userQuery.StatusInReplyToUserID = xmlDoc.SelectSingleNode("/user/status/in_reply_to_user_id") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_user_id").InnerText : string.Empty;
                            userQuery.StatusFavorited = xmlDoc.SelectSingleNode("/user/status/favorited") != null ? xmlDoc.SelectSingleNode("/user/status/favorited").InnerText : string.Empty;
                            userQuery.StatusInReplyToScreenName = xmlDoc.SelectSingleNode("/user/status/in_reply_to_screen_name") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_screen_name").InnerText : string.Empty;

                            break;
                        }
                    case SearchType.ByUserID:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/users/show.xml?user_id=" + search);
                            XmlDocument xmlDoc = new XmlDocument();
                            xmlDoc.Load(feedReader);

                            userQuery.ID = xmlDoc.SelectSingleNode("/user/id") != null ? xmlDoc.SelectSingleNode("/user/id").InnerText : string.Empty;
                            userQuery.Name = xmlDoc.SelectSingleNode("/user/name") != null ? xmlDoc.SelectSingleNode("/user/name").InnerText : string.Empty;
                            userQuery.ScreenName = xmlDoc.SelectSingleNode("/user/screen_name") != null ? xmlDoc.SelectSingleNode("/user/screen_name").InnerText : string.Empty;
                            userQuery.Location = xmlDoc.SelectSingleNode("/user/location") != null ? xmlDoc.SelectSingleNode("/user/location").InnerText : string.Empty;
                            userQuery.Description = xmlDoc.SelectSingleNode("/user/description") != null ? xmlDoc.SelectSingleNode("/user/description").InnerText : string.Empty;
                            userQuery.ProfileImageURL = xmlDoc.SelectSingleNode("/user/profile_image_url") != null ? xmlDoc.SelectSingleNode("/user/profile_image_url").InnerText : string.Empty;
                            userQuery.URL = xmlDoc.SelectSingleNode("/user/url") != null ? xmlDoc.SelectSingleNode("/user/url").InnerText : string.Empty;
                            userQuery.Protected = xmlDoc.SelectSingleNode("/user/protected") != null ? xmlDoc.SelectSingleNode("/user/protected").InnerText : string.Empty;
                            userQuery.Followers = xmlDoc.SelectSingleNode("/user/followers_count") != null ? xmlDoc.SelectSingleNode("/user/followers_count").InnerText : string.Empty;
                            userQuery.ProfileBackgroundColor = xmlDoc.SelectSingleNode("/user/profile_background_color") != null ? xmlDoc.SelectSingleNode("/user/profile_background_color").InnerText : string.Empty;
                            userQuery.ProfileTextColor = xmlDoc.SelectSingleNode("/user/profile_text_color") != null ? xmlDoc.SelectSingleNode("/user/profile_text_color").InnerText : string.Empty;
                            userQuery.ProfileLinkColor = xmlDoc.SelectSingleNode("/user/profile_link_color") != null ? xmlDoc.SelectSingleNode("/user/profile_link_color").InnerText : string.Empty;
                            userQuery.ProfileSidebarFillColor = xmlDoc.SelectSingleNode("/user/profile_sidebar_fill_color") != null ? xmlDoc.SelectSingleNode("/user/profile_sidebar_fill_color").InnerText : string.Empty;
                            userQuery.ProfileSidebarBorderColor = xmlDoc.SelectSingleNode("/user/profile_sidebar_border_color") != null ? xmlDoc.SelectSingleNode("/user/profile_sidebar_border_color").InnerText : string.Empty;
                            userQuery.FriendsCount = xmlDoc.SelectSingleNode("/user/friends_count") != null ? xmlDoc.SelectSingleNode("/user/friends_count").InnerText : string.Empty;
                            userQuery.UtcOffset = xmlDoc.SelectSingleNode("/user/utc_offset") != null ? xmlDoc.SelectSingleNode("/user/utc_offset").InnerText : string.Empty;
                            userQuery.TimeZone = xmlDoc.SelectSingleNode("/user/time_zone") != null ? xmlDoc.SelectSingleNode("/user/time_zone").InnerText : string.Empty;
                            userQuery.ProfileBackgroundImageUrl = xmlDoc.SelectSingleNode("/user/profile_background_image_url") != null ? xmlDoc.SelectSingleNode("/user/profile_background_image_url").InnerText : string.Empty;
                            userQuery.ProfileBackgroundTile = xmlDoc.SelectSingleNode("/user/profile_background_tile") != null ? xmlDoc.SelectSingleNode("/user/profile_background_tile").InnerText : string.Empty;
                            userQuery.StatusesCount = xmlDoc.SelectSingleNode("/user/statuses_count") != null ? xmlDoc.SelectSingleNode("/user/statuses_count").InnerText : string.Empty;
                            userQuery.Notifications = xmlDoc.SelectSingleNode("/user/notifications") != null ? xmlDoc.SelectSingleNode("/user/notifications").InnerText : string.Empty;
                            userQuery.Following = xmlDoc.SelectSingleNode("/user/following") != null ? xmlDoc.SelectSingleNode("/user/following").InnerText : string.Empty;
                            userQuery.Verified = xmlDoc.SelectSingleNode("/user/verified") != null ? xmlDoc.SelectSingleNode("/user/verified").InnerText : string.Empty;
                            userQuery.StatusCreatedAt = xmlDoc.SelectSingleNode("/user/status/created_at") != null ? xmlDoc.SelectSingleNode("/user/status/created_at").InnerText : string.Empty;
                            userQuery.StatusID = xmlDoc.SelectSingleNode("/user/status/id") != null ? xmlDoc.SelectSingleNode("/user/status/id").InnerText : string.Empty;
                            userQuery.StatusText = xmlDoc.SelectSingleNode("/user/status/text") != null ? xmlDoc.SelectSingleNode("/user/status/text").InnerText : string.Empty;
                            userQuery.StatusSource = xmlDoc.SelectSingleNode("/user/status/source") != null ? xmlDoc.SelectSingleNode("/user/status/source").InnerText : string.Empty;
                            userQuery.StatusTruncated = xmlDoc.SelectSingleNode("/user/status/truncated") != null ? xmlDoc.SelectSingleNode("/user/status/truncated").InnerText : string.Empty;
                            userQuery.StatusInReplyToStatusID = xmlDoc.SelectSingleNode("/user/status/in_reply_to_status_id") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_status_id").InnerText : string.Empty;
                            userQuery.StatusInReplyToUserID = xmlDoc.SelectSingleNode("/user/status/in_reply_to_user_id") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_user_id").InnerText : string.Empty;
                            userQuery.StatusFavorited = xmlDoc.SelectSingleNode("/user/status/favorited") != null ? xmlDoc.SelectSingleNode("/user/status/favorited").InnerText : string.Empty;
                            userQuery.StatusInReplyToScreenName = xmlDoc.SelectSingleNode("/user/status/in_reply_to_screen_name") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_screen_name").InnerText : string.Empty;

                            break;
                        }
                }

                return userQuery;
            }
            catch
            {
                return null;
            }
        }

        #endregion

        #region Statuses/Friends
        /// <summary>
        /// Returns a user's friends, each with current status inline. 
        /// They are ordered by the order in which they were added as 
        /// friends, 100 at a time. (Please note that the result set isn't 
        /// guaranteed to be 100 every time as suspended users will be filtered out.) 
        /// Use the page option to access older friends. With no user specified, 
        /// request defaults to the authenticated user's friends. It's also possible 
        /// to request another user's friends list via the id, screen_name or user_id parameter.
        /// http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses%C2%A0friends
        /// </summary>

        public enum Parameters
        {
            ByID,
            ByUserID,
            ByScreenName
        }

        /// <param name="param">The parameter that indicates the type of search.</param>
        /// <param name="search">The search string/ID.</param>
        public static ArrayList Statuses_Friends(Parameters param, string search)
        {
            try
            {
                ArrayList sfArray = new ArrayList();

                switch (param)
                {
                    case Parameters.ByID:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/friends/" + search + ".xml");
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            foreach (XmlNode myNode in xmlDocument.SelectNodes("/users/user"))
                            {
                                User userQuery = new User();

                                userQuery.ID = myNode.SelectSingleNode("id") != null ? myNode.SelectSingleNode("id").InnerText : string.Empty;
                                userQuery.Name = myNode.SelectSingleNode("name") != null ? myNode.SelectSingleNode("name").InnerText : string.Empty;
                                userQuery.ScreenName = myNode.SelectSingleNode("screen_name") != null ? myNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                userQuery.Location = myNode.SelectSingleNode("location") != null ? myNode.SelectSingleNode("location").InnerText : string.Empty;
                                userQuery.Description = myNode.SelectSingleNode("description") != null ? myNode.SelectSingleNode("description").InnerText : string.Empty;
                                userQuery.ProfileImageURL = myNode.SelectSingleNode("profile_image_url") != null ? myNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                userQuery.URL = myNode.SelectSingleNode("url") != null ? myNode.SelectSingleNode("url").InnerText : string.Empty;
                                userQuery.Protected = myNode.SelectSingleNode("protected") != null ? myNode.SelectSingleNode("protected").InnerText : string.Empty;
                                userQuery.Followers = myNode.SelectSingleNode("followers_count") != null ? myNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                userQuery.ProfileBackgroundColor = myNode.SelectSingleNode("profile_background_color") != null ? myNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                userQuery.ProfileTextColor = myNode.SelectSingleNode("profile_text_color") != null ? myNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                userQuery.ProfileLinkColor = myNode.SelectSingleNode("profile_link_color") != null ? myNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                userQuery.ProfileSidebarFillColor = myNode.SelectSingleNode("profile_sidebar_fill_color") != null ? myNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                userQuery.ProfileSidebarBorderColor = myNode.SelectSingleNode("profile_sidebar_border_color") != null ? myNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                userQuery.FriendsCount = myNode.SelectSingleNode("friends_count") != null ? myNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                userQuery.UtcOffset = myNode.SelectSingleNode("utc_offset") != null ? myNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                userQuery.TimeZone = myNode.SelectSingleNode("time_zone") != null ? myNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                userQuery.ProfileBackgroundImageUrl = myNode.SelectSingleNode("profile_background_image_url") != null ? myNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                userQuery.ProfileBackgroundTile = myNode.SelectSingleNode("profile_background_tile") != null ? myNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                userQuery.StatusesCount = myNode.SelectSingleNode("statuses_count") != null ? myNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                userQuery.Notifications = myNode.SelectSingleNode("notifications") != null ? myNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                userQuery.Following = myNode.SelectSingleNode("following") != null ? myNode.SelectSingleNode("following").InnerText : string.Empty;
                                userQuery.Verified = myNode.SelectSingleNode("verified") != null ? myNode.SelectSingleNode("verified").InnerText : string.Empty;
                                userQuery.StatusCreatedAt = myNode.SelectSingleNode("status/created_at") != null ? myNode.SelectSingleNode("status/created_at").InnerText : string.Empty;
                                userQuery.StatusID = myNode.SelectSingleNode("status/id") != null ? myNode.SelectSingleNode("status/id").InnerText : string.Empty;
                                userQuery.StatusText = myNode.SelectSingleNode("status/text") != null ? myNode.SelectSingleNode("status/text").InnerText : string.Empty;
                                userQuery.StatusSource = myNode.SelectSingleNode("status/source") != null ? myNode.SelectSingleNode("status/source").InnerText : string.Empty;
                                userQuery.StatusTruncated = myNode.SelectSingleNode("status/truncated") != null ? myNode.SelectSingleNode("status/truncated").InnerText : string.Empty;
                                userQuery.StatusInReplyToStatusID = myNode.SelectSingleNode("status/in_reply_to_status_id") != null ? myNode.SelectSingleNode("status/in_reply_to_status_id").InnerText : string.Empty;
                                userQuery.StatusInReplyToUserID = myNode.SelectSingleNode("status/in_reply_to_user_id") != null ? myNode.SelectSingleNode("status/in_reply_to_user_id").InnerText : string.Empty;
                                userQuery.StatusFavorited = myNode.SelectSingleNode("status/favorited") != null ? myNode.SelectSingleNode("status/favorited").InnerText : string.Empty;
                                userQuery.StatusInReplyToScreenName = myNode.SelectSingleNode("status/in_reply_to_screen_name") != null ? myNode.SelectSingleNode("status/in_reply_to_screen_name").InnerText : string.Empty;

                                sfArray.Add(userQuery);
                            }
                            break;
                        }
                    case Parameters.ByScreenName:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/friends.xml?screen_name=" + search);
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            foreach (XmlNode myNode in xmlDocument.SelectNodes("/users/user"))
                            {
                                User userQuery = new User();

                                userQuery.ID = myNode.SelectSingleNode("id") != null ? myNode.SelectSingleNode("id").InnerText : string.Empty;
                                userQuery.Name = myNode.SelectSingleNode("name") != null ? myNode.SelectSingleNode("name").InnerText : string.Empty;
                                userQuery.ScreenName = myNode.SelectSingleNode("screen_name") != null ? myNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                userQuery.Location = myNode.SelectSingleNode("location") != null ? myNode.SelectSingleNode("location").InnerText : string.Empty;
                                userQuery.Description = myNode.SelectSingleNode("description") != null ? myNode.SelectSingleNode("description").InnerText : string.Empty;
                                userQuery.ProfileImageURL = myNode.SelectSingleNode("profile_image_url") != null ? myNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                userQuery.URL = myNode.SelectSingleNode("url") != null ? myNode.SelectSingleNode("url").InnerText : string.Empty;
                                userQuery.Protected = myNode.SelectSingleNode("protected") != null ? myNode.SelectSingleNode("protected").InnerText : string.Empty;
                                userQuery.Followers = myNode.SelectSingleNode("followers_count") != null ? myNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                userQuery.ProfileBackgroundColor = myNode.SelectSingleNode("profile_background_color") != null ? myNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                userQuery.ProfileTextColor = myNode.SelectSingleNode("profile_text_color") != null ? myNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                userQuery.ProfileLinkColor = myNode.SelectSingleNode("profile_link_color") != null ? myNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                userQuery.ProfileSidebarFillColor = myNode.SelectSingleNode("profile_sidebar_fill_color") != null ? myNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                userQuery.ProfileSidebarBorderColor = myNode.SelectSingleNode("profile_sidebar_border_color") != null ? myNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                userQuery.FriendsCount = myNode.SelectSingleNode("friends_count") != null ? myNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                userQuery.UtcOffset = myNode.SelectSingleNode("utc_offset") != null ? myNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                userQuery.TimeZone = myNode.SelectSingleNode("time_zone") != null ? myNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                userQuery.ProfileBackgroundImageUrl = myNode.SelectSingleNode("profile_background_image_url") != null ? myNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                userQuery.ProfileBackgroundTile = myNode.SelectSingleNode("profile_background_tile") != null ? myNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                userQuery.StatusesCount = myNode.SelectSingleNode("statuses_count") != null ? myNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                userQuery.Notifications = myNode.SelectSingleNode("notifications") != null ? myNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                userQuery.Following = myNode.SelectSingleNode("following") != null ? myNode.SelectSingleNode("following").InnerText : string.Empty;
                                userQuery.Verified = myNode.SelectSingleNode("verified") != null ? myNode.SelectSingleNode("verified").InnerText : string.Empty;
                                userQuery.StatusCreatedAt = myNode.SelectSingleNode("status/created_at") != null ? myNode.SelectSingleNode("status/created_at").InnerText : string.Empty;
                                userQuery.StatusID = myNode.SelectSingleNode("status/id") != null ? myNode.SelectSingleNode("status/id").InnerText : string.Empty;
                                userQuery.StatusText = myNode.SelectSingleNode("status/text") != null ? myNode.SelectSingleNode("status/text").InnerText : string.Empty;
                                userQuery.StatusSource = myNode.SelectSingleNode("status/source") != null ? myNode.SelectSingleNode("status/source").InnerText : string.Empty;
                                userQuery.StatusTruncated = myNode.SelectSingleNode("status/truncated") != null ? myNode.SelectSingleNode("status/truncated").InnerText : string.Empty;
                                userQuery.StatusInReplyToStatusID = myNode.SelectSingleNode("status/in_reply_to_status_id") != null ? myNode.SelectSingleNode("status/in_reply_to_status_id").InnerText : string.Empty;
                                userQuery.StatusInReplyToUserID = myNode.SelectSingleNode("status/in_reply_to_user_id") != null ? myNode.SelectSingleNode("status/in_reply_to_user_id").InnerText : string.Empty;
                                userQuery.StatusFavorited = myNode.SelectSingleNode("status/favorited") != null ? myNode.SelectSingleNode("status/favorited").InnerText : string.Empty;
                                userQuery.StatusInReplyToScreenName = myNode.SelectSingleNode("status/in_reply_to_screen_name") != null ? myNode.SelectSingleNode("status/in_reply_to_screen_name").InnerText : string.Empty;

                                sfArray.Add(userQuery);
                            }

                            break;
                        }
                    case Parameters.ByUserID:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/friends.xml?user_id=" + search);
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            foreach (XmlNode myNode in xmlDocument.SelectNodes("/users/user"))
                            {
                                User userQuery = new User();

                                userQuery.ID = myNode.SelectSingleNode("id") != null ? myNode.SelectSingleNode("id").InnerText : string.Empty;
                                userQuery.Name = myNode.SelectSingleNode("name") != null ? myNode.SelectSingleNode("name").InnerText : string.Empty;
                                userQuery.ScreenName = myNode.SelectSingleNode("screen_name") != null ? myNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                userQuery.Location = myNode.SelectSingleNode("location") != null ? myNode.SelectSingleNode("location").InnerText : string.Empty;
                                userQuery.Description = myNode.SelectSingleNode("description") != null ? myNode.SelectSingleNode("description").InnerText : string.Empty;
                                userQuery.ProfileImageURL = myNode.SelectSingleNode("profile_image_url") != null ? myNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                userQuery.URL = myNode.SelectSingleNode("url") != null ? myNode.SelectSingleNode("url").InnerText : string.Empty;
                                userQuery.Protected = myNode.SelectSingleNode("protected") != null ? myNode.SelectSingleNode("protected").InnerText : string.Empty;
                                userQuery.Followers = myNode.SelectSingleNode("followers_count") != null ? myNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                userQuery.ProfileBackgroundColor = myNode.SelectSingleNode("profile_background_color") != null ? myNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                userQuery.ProfileTextColor = myNode.SelectSingleNode("profile_text_color") != null ? myNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                userQuery.ProfileLinkColor = myNode.SelectSingleNode("profile_link_color") != null ? myNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                userQuery.ProfileSidebarFillColor = myNode.SelectSingleNode("profile_sidebar_fill_color") != null ? myNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                userQuery.ProfileSidebarBorderColor = myNode.SelectSingleNode("profile_sidebar_border_color") != null ? myNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                userQuery.FriendsCount = myNode.SelectSingleNode("friends_count") != null ? myNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                userQuery.UtcOffset = myNode.SelectSingleNode("utc_offset") != null ? myNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                userQuery.TimeZone = myNode.SelectSingleNode("time_zone") != null ? myNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                userQuery.ProfileBackgroundImageUrl = myNode.SelectSingleNode("profile_background_image_url") != null ? myNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                userQuery.ProfileBackgroundTile = myNode.SelectSingleNode("profile_background_tile") != null ? myNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                userQuery.StatusesCount = myNode.SelectSingleNode("statuses_count") != null ? myNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                userQuery.Notifications = myNode.SelectSingleNode("notifications") != null ? myNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                userQuery.Following = myNode.SelectSingleNode("following") != null ? myNode.SelectSingleNode("following").InnerText : string.Empty;
                                userQuery.Verified = myNode.SelectSingleNode("verified") != null ? myNode.SelectSingleNode("verified").InnerText : string.Empty;
                                userQuery.StatusCreatedAt = myNode.SelectSingleNode("status/created_at") != null ? myNode.SelectSingleNode("status/created_at").InnerText : string.Empty;
                                userQuery.StatusID = myNode.SelectSingleNode("status/id") != null ? myNode.SelectSingleNode("status/id").InnerText : string.Empty;
                                userQuery.StatusText = myNode.SelectSingleNode("status/text") != null ? myNode.SelectSingleNode("status/text").InnerText : string.Empty;
                                userQuery.StatusSource = myNode.SelectSingleNode("status/source") != null ? myNode.SelectSingleNode("status/source").InnerText : string.Empty;
                                userQuery.StatusTruncated = myNode.SelectSingleNode("status/truncated") != null ? myNode.SelectSingleNode("status/truncated").InnerText : string.Empty;
                                userQuery.StatusInReplyToStatusID = myNode.SelectSingleNode("status/in_reply_to_status_id") != null ? myNode.SelectSingleNode("status/in_reply_to_status_id").InnerText : string.Empty;
                                userQuery.StatusInReplyToUserID = myNode.SelectSingleNode("status/in_reply_to_user_id") != null ? myNode.SelectSingleNode("status/in_reply_to_user_id").InnerText : string.Empty;
                                userQuery.StatusFavorited = myNode.SelectSingleNode("status/favorited") != null ? myNode.SelectSingleNode("status/favorited").InnerText : string.Empty;
                                userQuery.StatusInReplyToScreenName = myNode.SelectSingleNode("status/in_reply_to_screen_name") != null ? myNode.SelectSingleNode("status/in_reply_to_screen_name").InnerText : string.Empty;

                                sfArray.Add(userQuery);
                            }

                            break;
                        }
                }
                return sfArray;
            }
            catch
            {
                return null;
            }
        }


        public static ArrayList Statuses_Friends(string username, string password, string page)
        {
            try
            {
                ArrayList sfArray = new ArrayList();

                XmlUrlResolver xmlResolver = new XmlUrlResolver();
                xmlResolver.Credentials = new NetworkCredential(username, password);

                XmlReaderSettings xmlSettings = new XmlReaderSettings();
                xmlSettings.XmlResolver = xmlResolver;

                XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/friends.xml?page=" + page, xmlSettings);
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(feedReader);

                foreach (XmlNode myNode in xmlDocument.SelectNodes("/users/user"))
                {
                    User userQuery = new User();

                    userQuery.ID = myNode.SelectSingleNode("id") != null ? myNode.SelectSingleNode("id").InnerText : string.Empty;
                    userQuery.Name = myNode.SelectSingleNode("name") != null ? myNode.SelectSingleNode("name").InnerText : string.Empty;
                    userQuery.ScreenName = myNode.SelectSingleNode("screen_name") != null ? myNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                    userQuery.Location = myNode.SelectSingleNode("location") != null ? myNode.SelectSingleNode("location").InnerText : string.Empty;
                    userQuery.Description = myNode.SelectSingleNode("description") != null ? myNode.SelectSingleNode("description").InnerText : string.Empty;
                    userQuery.ProfileImageURL = myNode.SelectSingleNode("profile_image_url") != null ? myNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                    userQuery.URL = myNode.SelectSingleNode("url") != null ? myNode.SelectSingleNode("url").InnerText : string.Empty;
                    userQuery.Protected = myNode.SelectSingleNode("protected") != null ? myNode.SelectSingleNode("protected").InnerText : string.Empty;
                    userQuery.Followers = myNode.SelectSingleNode("followers_count") != null ? myNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                    userQuery.ProfileBackgroundColor = myNode.SelectSingleNode("profile_background_color") != null ? myNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                    userQuery.ProfileTextColor = myNode.SelectSingleNode("profile_text_color") != null ? myNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                    userQuery.ProfileLinkColor = myNode.SelectSingleNode("profile_link_color") != null ? myNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                    userQuery.ProfileSidebarFillColor = myNode.SelectSingleNode("profile_sidebar_fill_color") != null ? myNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                    userQuery.ProfileSidebarBorderColor = myNode.SelectSingleNode("profile_sidebar_border_color") != null ? myNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                    userQuery.FriendsCount = myNode.SelectSingleNode("friends_count") != null ? myNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                    userQuery.UtcOffset = myNode.SelectSingleNode("utc_offset") != null ? myNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                    userQuery.TimeZone = myNode.SelectSingleNode("time_zone") != null ? myNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                    userQuery.ProfileBackgroundImageUrl = myNode.SelectSingleNode("profile_background_image_url") != null ? myNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                    userQuery.ProfileBackgroundTile = myNode.SelectSingleNode("profile_background_tile") != null ? myNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                    userQuery.StatusesCount = myNode.SelectSingleNode("statuses_count") != null ? myNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                    userQuery.Notifications = myNode.SelectSingleNode("notifications") != null ? myNode.SelectSingleNode("notifications").InnerText : string.Empty;
                    userQuery.Following = myNode.SelectSingleNode("following") != null ? myNode.SelectSingleNode("following").InnerText : string.Empty;
                    userQuery.Verified = myNode.SelectSingleNode("verified") != null ? myNode.SelectSingleNode("verified").InnerText : string.Empty;
                    userQuery.StatusCreatedAt = myNode.SelectSingleNode("status/created_at") != null ? myNode.SelectSingleNode("status/created_at").InnerText : string.Empty;
                    userQuery.StatusID = myNode.SelectSingleNode("status/id") != null ? myNode.SelectSingleNode("status/id").InnerText : string.Empty;
                    userQuery.StatusText = myNode.SelectSingleNode("status/text") != null ? myNode.SelectSingleNode("status/text").InnerText : string.Empty;
                    userQuery.StatusSource = myNode.SelectSingleNode("status/source") != null ? myNode.SelectSingleNode("status/source").InnerText : string.Empty;
                    userQuery.StatusTruncated = myNode.SelectSingleNode("status/truncated") != null ? myNode.SelectSingleNode("status/truncated").InnerText : string.Empty;
                    userQuery.StatusInReplyToStatusID = myNode.SelectSingleNode("status/in_reply_to_status_id") != null ? myNode.SelectSingleNode("status/in_reply_to_status_id").InnerText : string.Empty;
                    userQuery.StatusInReplyToUserID = myNode.SelectSingleNode("status/in_reply_to_user_id") != null ? myNode.SelectSingleNode("status/in_reply_to_user_id").InnerText : string.Empty;
                    userQuery.StatusFavorited = myNode.SelectSingleNode("status/favorited") != null ? myNode.SelectSingleNode("status/favorited").InnerText : string.Empty;
                    userQuery.StatusInReplyToScreenName = myNode.SelectSingleNode("status/in_reply_to_screen_name") != null ? myNode.SelectSingleNode("status/in_reply_to_screen_name").InnerText : string.Empty;

                    sfArray.Add(userQuery);
                }
                return sfArray;
            }
            catch
            {
                return null;
            }
        }

        #endregion

        #region Statuses / Followers

        public enum StatusesParam
        {
            ByID,
            ByScreenName,
            ByPage,
            ByUserID
        }
        /// <summary>
        /// Returns the authenticating user's followers, each with current status inline.
        /// They are ordered by the order in which they joined Twitter, 100 at a time. 
        /// (Please note that the result set isn't guaranteed to be 100 every time as suspended 
        /// users will be filtered out.) Use the page option to access earlier followers.
        /// http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-statuses%C2%A0followers
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        /// <param name="param">The search type parameter.</param>
        /// <param name="search">The searched string/ID.</param>
        public static ArrayList Statuses_Followers(string username, string password, StatusesParam param, string search)
        {
            try
            {
                ArrayList sfArray = new ArrayList();

                XmlUrlResolver xmlResolver = new XmlUrlResolver();
                xmlResolver.Credentials = new NetworkCredential(username, password);

                XmlReaderSettings xmlSettings = new XmlReaderSettings();
                xmlSettings.XmlResolver = xmlResolver;

                switch (param)
                {
                    case StatusesParam.ByID:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/followers/" + search + ".xml", xmlSettings);
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            foreach (XmlNode myNode in xmlDocument.SelectNodes("/users/user"))
                            {
                                User userQuery = new User();

                                userQuery.ID = myNode.SelectSingleNode("id") != null ? myNode.SelectSingleNode("id").InnerText : string.Empty;
                                userQuery.Name = myNode.SelectSingleNode("name") != null ? myNode.SelectSingleNode("name").InnerText : string.Empty;
                                userQuery.ScreenName = myNode.SelectSingleNode("screen_name") != null ? myNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                userQuery.Location = myNode.SelectSingleNode("location") != null ? myNode.SelectSingleNode("location").InnerText : string.Empty;
                                userQuery.Description = myNode.SelectSingleNode("description") != null ? myNode.SelectSingleNode("description").InnerText : string.Empty;
                                userQuery.ProfileImageURL = myNode.SelectSingleNode("profile_image_url") != null ? myNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                userQuery.URL = myNode.SelectSingleNode("url") != null ? myNode.SelectSingleNode("url").InnerText : string.Empty;
                                userQuery.Protected = myNode.SelectSingleNode("protected") != null ? myNode.SelectSingleNode("protected").InnerText : string.Empty;
                                userQuery.Followers = myNode.SelectSingleNode("followers_count") != null ? myNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                userQuery.ProfileBackgroundColor = myNode.SelectSingleNode("profile_background_color").InnerText != null ? myNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                userQuery.ProfileTextColor = myNode.SelectSingleNode("profile_text_color") != null ? myNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                userQuery.ProfileLinkColor = myNode.SelectSingleNode("profile_link_color") != null ? myNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                userQuery.ProfileSidebarFillColor = myNode.SelectSingleNode("profile_sidebar_fill_color") != null ? myNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                userQuery.ProfileSidebarBorderColor = myNode.SelectSingleNode("profile_sidebar_border_color") != null ? myNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                userQuery.FriendsCount = myNode.SelectSingleNode("friends_count") != null ? myNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                userQuery.UtcOffset = myNode.SelectSingleNode("utc_offset") != null ? myNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                userQuery.TimeZone = myNode.SelectSingleNode("time_zone") != null ? myNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                userQuery.ProfileBackgroundImageUrl = myNode.SelectSingleNode("profile_background_image_url") != null ? myNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                userQuery.ProfileBackgroundTile = myNode.SelectSingleNode("profile_background_tile") != null ? myNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                userQuery.StatusesCount = myNode.SelectSingleNode("statuses_count") != null ? myNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                userQuery.Notifications = myNode.SelectSingleNode("notifications") != null ? myNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                userQuery.Following = myNode.SelectSingleNode("following") != null ? myNode.SelectSingleNode("following").InnerText : string.Empty;
                                userQuery.Verified = myNode.SelectSingleNode("verified") != null ? myNode.SelectSingleNode("verified").InnerText : string.Empty;
                                userQuery.StatusCreatedAt = myNode.SelectSingleNode("status/created_at") != null ? myNode.SelectSingleNode("status/created_at").InnerText : string.Empty;
                                userQuery.StatusID = myNode.SelectSingleNode("status/id") != null ? myNode.SelectSingleNode("status/id").InnerText : string.Empty;
                                userQuery.StatusText = myNode.SelectSingleNode("status/text") != null ? myNode.SelectSingleNode("status/text").InnerText : string.Empty;
                                userQuery.StatusSource = myNode.SelectSingleNode("status/source") != null ? myNode.SelectSingleNode("status/source").InnerText : string.Empty;
                                userQuery.StatusTruncated = myNode.SelectSingleNode("status/truncated") != null ? myNode.SelectSingleNode("status/truncated").InnerText : string.Empty;
                                userQuery.StatusInReplyToStatusID = myNode.SelectSingleNode("status/in_reply_to_status_id") != null ? myNode.SelectSingleNode("status/in_reply_to_status_id").InnerText : string.Empty;
                                userQuery.StatusInReplyToUserID = myNode.SelectSingleNode("status/in_reply_to_user_id") != null ? myNode.SelectSingleNode("status/in_reply_to_user_id").InnerText : string.Empty;
                                userQuery.StatusFavorited = myNode.SelectSingleNode("status/favorited") != null ? myNode.SelectSingleNode("status/favorited").InnerText : string.Empty;
                                userQuery.StatusInReplyToScreenName = myNode.SelectSingleNode("status/in_reply_to_screen_name") != null ? myNode.SelectSingleNode("status/in_reply_to_screen_name").InnerText : string.Empty;

                                sfArray.Add(userQuery);
                            }
                            break;
                        }
                    case StatusesParam.ByScreenName:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/followers.xml?screen_name=" + search, xmlSettings);
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            foreach (XmlNode myNode in xmlDocument.SelectNodes("/users/user"))
                            {
                                User userQuery = new User();

                                userQuery.ID = myNode.SelectSingleNode("id") != null ? myNode.SelectSingleNode("id").InnerText : string.Empty;
                                userQuery.Name = myNode.SelectSingleNode("name") != null ? myNode.SelectSingleNode("name").InnerText : string.Empty;
                                userQuery.ScreenName = myNode.SelectSingleNode("screen_name") != null ? myNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                userQuery.Location = myNode.SelectSingleNode("location") != null ? myNode.SelectSingleNode("location").InnerText : string.Empty;
                                userQuery.Description = myNode.SelectSingleNode("description") != null ? myNode.SelectSingleNode("description").InnerText : string.Empty;
                                userQuery.ProfileImageURL = myNode.SelectSingleNode("profile_image_url") != null ? myNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                userQuery.URL = myNode.SelectSingleNode("url") != null ? myNode.SelectSingleNode("url").InnerText : string.Empty;
                                userQuery.Protected = myNode.SelectSingleNode("protected") != null ? myNode.SelectSingleNode("protected").InnerText : string.Empty;
                                userQuery.Followers = myNode.SelectSingleNode("followers_count") != null ? myNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                userQuery.ProfileBackgroundColor = myNode.SelectSingleNode("profile_background_color") != null ? myNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                userQuery.ProfileTextColor = myNode.SelectSingleNode("profile_text_color") != null ? myNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                userQuery.ProfileLinkColor = myNode.SelectSingleNode("profile_link_color") != null ? myNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                userQuery.ProfileSidebarFillColor = myNode.SelectSingleNode("profile_sidebar_fill_color") != null ? myNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                userQuery.ProfileSidebarBorderColor = myNode.SelectSingleNode("profile_sidebar_border_color") != null ? myNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                userQuery.FriendsCount = myNode.SelectSingleNode("friends_count") != null ? myNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                userQuery.UtcOffset = myNode.SelectSingleNode("utc_offset") != null ? myNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                userQuery.TimeZone = myNode.SelectSingleNode("time_zone") != null ? myNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                userQuery.ProfileBackgroundImageUrl = myNode.SelectSingleNode("profile_background_image_url") != null ? myNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                userQuery.ProfileBackgroundTile = myNode.SelectSingleNode("profile_background_tile") != null ? myNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                userQuery.StatusesCount = myNode.SelectSingleNode("statuses_count") != null ? myNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                userQuery.Notifications = myNode.SelectSingleNode("notifications") != null ? myNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                userQuery.Following = myNode.SelectSingleNode("following") != null ? myNode.SelectSingleNode("following").InnerText : string.Empty;
                                userQuery.Verified = myNode.SelectSingleNode("verified") != null ? myNode.SelectSingleNode("verified").InnerText : string.Empty;
                                userQuery.StatusCreatedAt = myNode.SelectSingleNode("status/created_at") != null ? myNode.SelectSingleNode("status/created_at").InnerText : string.Empty;
                                userQuery.StatusID = myNode.SelectSingleNode("status/id") != null ? myNode.SelectSingleNode("status/id").InnerText : string.Empty;
                                userQuery.StatusText = myNode.SelectSingleNode("status/text") != null ? myNode.SelectSingleNode("status/text").InnerText : string.Empty;
                                userQuery.StatusSource = myNode.SelectSingleNode("status/source") != null ? myNode.SelectSingleNode("status/source").InnerText : string.Empty;
                                userQuery.StatusTruncated = myNode.SelectSingleNode("status/truncated") != null ? myNode.SelectSingleNode("status/truncated").InnerText : string.Empty;
                                userQuery.StatusInReplyToStatusID = myNode.SelectSingleNode("status/in_reply_to_status_id") != null ? myNode.SelectSingleNode("status/in_reply_to_status_id").InnerText : string.Empty;
                                userQuery.StatusInReplyToUserID = myNode.SelectSingleNode("status/in_reply_to_user_id") != null ? myNode.SelectSingleNode("status/in_reply_to_user_id").InnerText : string.Empty;
                                userQuery.StatusFavorited = myNode.SelectSingleNode("status/favorited") != null ? myNode.SelectSingleNode("status/favorited").InnerText : string.Empty;
                                userQuery.StatusInReplyToScreenName = myNode.SelectSingleNode("status/in_reply_to_screen_name") != null ? myNode.SelectSingleNode("status/in_reply_to_screen_name").InnerText : string.Empty;

                                sfArray.Add(userQuery);
                            }
                            break;
                        }
                    case StatusesParam.ByUserID:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/followers.xml?user_id=" + search, xmlSettings);
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            foreach (XmlNode myNode in xmlDocument.SelectNodes("/users/user"))
                            {
                                User userQuery = new User();

                                userQuery.ID = myNode.SelectSingleNode("id") != null ? myNode.SelectSingleNode("id").InnerText : string.Empty;
                                userQuery.Name = myNode.SelectSingleNode("name") != null ? myNode.SelectSingleNode("name").InnerText : string.Empty;
                                userQuery.ScreenName = myNode.SelectSingleNode("screen_name") != null ? myNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                userQuery.Location = myNode.SelectSingleNode("location") != null ? myNode.SelectSingleNode("location").InnerText : string.Empty;
                                userQuery.Description = myNode.SelectSingleNode("description") != null ? myNode.SelectSingleNode("description").InnerText : string.Empty;
                                userQuery.ProfileImageURL = myNode.SelectSingleNode("profile_image_url") != null ? myNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                userQuery.URL = myNode.SelectSingleNode("url") != null ? myNode.SelectSingleNode("url").InnerText : string.Empty;
                                userQuery.Protected = myNode.SelectSingleNode("protected") != null ? myNode.SelectSingleNode("protected").InnerText : string.Empty;
                                userQuery.Followers = myNode.SelectSingleNode("followers_count") != null ? myNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                userQuery.ProfileBackgroundColor = myNode.SelectSingleNode("profile_background_color") != null ? myNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                userQuery.ProfileTextColor = myNode.SelectSingleNode("profile_text_color") != null ? myNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                userQuery.ProfileLinkColor = myNode.SelectSingleNode("profile_link_color") != null ? myNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                userQuery.ProfileSidebarFillColor = myNode.SelectSingleNode("profile_sidebar_fill_color") != null ? myNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                userQuery.ProfileSidebarBorderColor = myNode.SelectSingleNode("profile_sidebar_border_color") != null ? myNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                userQuery.FriendsCount = myNode.SelectSingleNode("friends_count") != null ? myNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                userQuery.UtcOffset = myNode.SelectSingleNode("utc_offset") != null ? myNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                userQuery.TimeZone = myNode.SelectSingleNode("time_zone") != null ? myNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                userQuery.ProfileBackgroundImageUrl = myNode.SelectSingleNode("profile_background_image_url") != null ? myNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                userQuery.ProfileBackgroundTile = myNode.SelectSingleNode("profile_background_tile") != null ? myNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                userQuery.StatusesCount = myNode.SelectSingleNode("statuses_count") != null ? myNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                userQuery.Notifications = myNode.SelectSingleNode("notifications") != null ? myNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                userQuery.Following = myNode.SelectSingleNode("following") != null ? myNode.SelectSingleNode("following").InnerText : string.Empty;
                                userQuery.Verified = myNode.SelectSingleNode("verified") != null ? myNode.SelectSingleNode("verified").InnerText : string.Empty;
                                userQuery.StatusCreatedAt = myNode.SelectSingleNode("status/created_at") != null ? myNode.SelectSingleNode("status/created_at").InnerText : string.Empty;
                                userQuery.StatusID = myNode.SelectSingleNode("status/id") != null ? myNode.SelectSingleNode("status/id").InnerText : string.Empty;
                                userQuery.StatusText = myNode.SelectSingleNode("status/text") != null ? myNode.SelectSingleNode("status/text").InnerText : string.Empty;
                                userQuery.StatusSource = myNode.SelectSingleNode("status/source") != null ? myNode.SelectSingleNode("status/source").InnerText : string.Empty;
                                userQuery.StatusTruncated = myNode.SelectSingleNode("status/truncated") != null ? myNode.SelectSingleNode("status/truncated").InnerText : string.Empty;
                                userQuery.StatusInReplyToStatusID = myNode.SelectSingleNode("status/in_reply_to_status_id") != null ? myNode.SelectSingleNode("status/in_reply_to_status_id").InnerText : string.Empty;
                                userQuery.StatusInReplyToUserID = myNode.SelectSingleNode("status/in_reply_to_user_id") != null ? myNode.SelectSingleNode("status/in_reply_to_user_id").InnerText : string.Empty;
                                userQuery.StatusFavorited = myNode.SelectSingleNode("status/favorited") != null ? myNode.SelectSingleNode("status/favorited").InnerText : string.Empty;
                                userQuery.StatusInReplyToScreenName = myNode.SelectSingleNode("status/in_reply_to_screen_name") != null ? myNode.SelectSingleNode("status/in_reply_to_screen_name").InnerText : string.Empty;

                                sfArray.Add(userQuery);
                            }
                            break;
                        }
                    case StatusesParam.ByPage:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/statuses/followers.xml?page=" + search, xmlSettings);
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            foreach (XmlNode myNode in xmlDocument.SelectNodes("/users/user"))
                            {
                                User userQuery = new User();

                                userQuery.ID = myNode.SelectSingleNode("id") != null ? myNode.SelectSingleNode("id").InnerText : string.Empty;
                                userQuery.Name = myNode.SelectSingleNode("name") != null ? myNode.SelectSingleNode("name").InnerText : string.Empty;
                                userQuery.ScreenName = myNode.SelectSingleNode("screen_name") != null ? myNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                userQuery.Location = myNode.SelectSingleNode("location") != null ? myNode.SelectSingleNode("location").InnerText : string.Empty;
                                userQuery.Description = myNode.SelectSingleNode("description") != null ? myNode.SelectSingleNode("description").InnerText : string.Empty;
                                userQuery.ProfileImageURL = myNode.SelectSingleNode("profile_image_url") != null ? myNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                userQuery.URL = myNode.SelectSingleNode("url") != null ? myNode.SelectSingleNode("url").InnerText : string.Empty;
                                userQuery.Protected = myNode.SelectSingleNode("protected") != null ? myNode.SelectSingleNode("protected").InnerText : string.Empty;
                                userQuery.Followers = myNode.SelectSingleNode("followers_count") != null ? myNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                userQuery.ProfileBackgroundColor = myNode.SelectSingleNode("profile_background_color") != null ? myNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                userQuery.ProfileTextColor = myNode.SelectSingleNode("profile_text_color") != null ? myNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                userQuery.ProfileLinkColor = myNode.SelectSingleNode("profile_link_color") != null ? myNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                userQuery.ProfileSidebarFillColor = myNode.SelectSingleNode("profile_sidebar_fill_color") != null ? myNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                userQuery.ProfileSidebarBorderColor = myNode.SelectSingleNode("profile_sidebar_border_color") != null ? myNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                userQuery.FriendsCount = myNode.SelectSingleNode("friends_count") != null ? myNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                userQuery.UtcOffset = myNode.SelectSingleNode("utc_offset") != null ? myNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                userQuery.TimeZone = myNode.SelectSingleNode("time_zone") != null ? myNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                userQuery.ProfileBackgroundImageUrl = myNode.SelectSingleNode("profile_background_image_url") != null ? myNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                userQuery.ProfileBackgroundTile = myNode.SelectSingleNode("profile_background_tile") != null ? myNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                userQuery.StatusesCount = myNode.SelectSingleNode("statuses_count") != null ? myNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                userQuery.Notifications = myNode.SelectSingleNode("notifications") != null ? myNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                userQuery.Following = myNode.SelectSingleNode("following") != null ? myNode.SelectSingleNode("following").InnerText : string.Empty;
                                userQuery.Verified = myNode.SelectSingleNode("verified") != null ? myNode.SelectSingleNode("verified").InnerText : string.Empty;
                                userQuery.StatusCreatedAt = myNode.SelectSingleNode("status/created_at") != null ? myNode.SelectSingleNode("status/created_at").InnerText : string.Empty;
                                userQuery.StatusID = myNode.SelectSingleNode("status/id") != null ? myNode.SelectSingleNode("status/id").InnerText : string.Empty;
                                userQuery.StatusText = myNode.SelectSingleNode("status/text") != null ? myNode.SelectSingleNode("status/text").InnerText : string.Empty;
                                userQuery.StatusSource = myNode.SelectSingleNode("status/source") != null ? myNode.SelectSingleNode("status/source").InnerText : string.Empty;
                                userQuery.StatusTruncated = myNode.SelectSingleNode("status/truncated") != null ? myNode.SelectSingleNode("status/truncated").InnerText : string.Empty;
                                userQuery.StatusInReplyToStatusID = myNode.SelectSingleNode("status/in_reply_to_status_id") != null ? myNode.SelectSingleNode("status/in_reply_to_status_id").InnerText : string.Empty;
                                userQuery.StatusInReplyToUserID = myNode.SelectSingleNode("status/in_reply_to_user_id") != null ? myNode.SelectSingleNode("status/in_reply_to_user_id").InnerText : string.Empty;
                                userQuery.StatusFavorited = myNode.SelectSingleNode("status/favorited") != null ? myNode.SelectSingleNode("status/favorited").InnerText : string.Empty;
                                userQuery.StatusInReplyToScreenName = myNode.SelectSingleNode("status/in_reply_to_screen_name") != null ? myNode.SelectSingleNode("status/in_reply_to_screen_name").InnerText : string.Empty;

                                sfArray.Add(userQuery);
                            }
                            break;
                        }
                }
                return sfArray;
            }
            catch
            {
                return null;
            }
        }

        #endregion

        #region Direct Messages


        /// <summary>
        /// Returns a list of the 20 most recent direct messages sent to the
        /// authenticating user.  The XML and JSON versions include detailed
        /// information about the sending and recipient users.
        /// http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-direct_messages
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        /// <param name="optional">Optional search parameter.</param>
        /// <param name="optionalValue">Optional search parameter value. (Required)</param>
        /// <returns></returns>
        public static ArrayList Direct_Message(string username, string password, Optional optional, string optionalValue)
        {
            try
            {
                ArrayList sfArray = new ArrayList();

                XmlUrlResolver xmlResolver = new XmlUrlResolver();
                xmlResolver.Credentials = new NetworkCredential(username, password);

                XmlReaderSettings xmlSettings = new XmlReaderSettings();
                xmlSettings.XmlResolver = xmlResolver;

                switch (optional)
                {
                    case Optional.Count:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/direct_messages.xml?count=" + optionalValue, xmlSettings);
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            foreach (XmlNode node in xmlDocument.SelectNodes("/direct-messages/direct_message"))
                            {
                                DirectMessage dm = new DirectMessage();

                                dm.ID = node.SelectSingleNode("id") != null ? node.SelectSingleNode("id").InnerText : string.Empty;
                                dm.SenderID = node.SelectSingleNode("sender_id") != null ? node.SelectSingleNode("sender_id").InnerText : string.Empty;
                                dm.Text = node.SelectSingleNode("text") != null ? node.SelectSingleNode("text").InnerText : string.Empty;
                                dm.RecipientID = node.SelectSingleNode("recipient_id") != null ? node.SelectSingleNode("recipient_id").InnerText : string.Empty;
                                dm.CreatedAt = node.SelectSingleNode("created_at") != null ? node.SelectSingleNode("created_at").InnerText : string.Empty;
                                dm.SenderScreenName = node.SelectSingleNode("sender_screen_name") != null ? node.SelectSingleNode("sender_screen_name").InnerText : string.Empty;
                                dm.RecipientScreenName = node.SelectSingleNode("recipient_screen_name") != null ? node.SelectSingleNode("recipient_screen_name").InnerText : string.Empty;

                                XmlNode sNode = node.SelectSingleNode("sender");

                                dm.Sender.ID = sNode.SelectSingleNode("id") != null ? sNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Sender.Name = sNode.SelectSingleNode("name") != null ? sNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Sender.ScreenName = sNode.SelectSingleNode("screen_name") != null ? sNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Sender.Location = sNode.SelectSingleNode("location") != null ? sNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Sender.Description = sNode.SelectSingleNode("description") != null ? sNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Sender.ProfileImageURL = sNode.SelectSingleNode("profile_image_url") != null ? sNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Sender.URL = sNode.SelectSingleNode("url") != null ? sNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Sender.Protected = sNode.SelectSingleNode("protected") != null ? sNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Sender.Followers = sNode.SelectSingleNode("followers_count") != null ? sNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundColor = sNode.SelectSingleNode("profile_background_color") != null ? sNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Sender.ProfileTextColor = sNode.SelectSingleNode("profile_text_color") != null ? sNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Sender.ProfileLinkColor = sNode.SelectSingleNode("profile_link_color") != null ? sNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarFillColor = sNode.SelectSingleNode("profile_sidebar_fill_color") != null ? sNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarBorderColor = sNode.SelectSingleNode("profile_sidebar_border_color") != null ? sNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Sender.FriendsCount = sNode.SelectSingleNode("friends_count") != null ? sNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Sender.UtcOffset = sNode.SelectSingleNode("utc_offset") != null ? sNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Sender.TimeZone = sNode.SelectSingleNode("time_zone") != null ? sNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundImageUrl = sNode.SelectSingleNode("profile_background_image_url") != null ? sNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundTile = sNode.SelectSingleNode("profile_background_tile") != null ? sNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Sender.StatusesCount = sNode.SelectSingleNode("statuses_count") != null ? sNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Sender.Notifications = sNode.SelectSingleNode("notifications") != null ? sNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Sender.Following = sNode.SelectSingleNode("following") != null ? sNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Sender.Verified = sNode.SelectSingleNode("verified") != null ? sNode.SelectSingleNode("verified").InnerText : string.Empty;


                                XmlNode myNode = node.SelectSingleNode("recipient");

                                dm.Recipient.ID = myNode.SelectSingleNode("id") != null ? myNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Recipient.Name = myNode.SelectSingleNode("name") != null ? myNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Recipient.ScreenName = myNode.SelectSingleNode("screen_name") != null ? myNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Recipient.Location = myNode.SelectSingleNode("location") != null ? myNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Recipient.Description = myNode.SelectSingleNode("description") != null ? myNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Recipient.ProfileImageURL = myNode.SelectSingleNode("profile_image_url") != null ? myNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Recipient.URL = myNode.SelectSingleNode("url") != null ? myNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Recipient.Protected = myNode.SelectSingleNode("protected") != null ? myNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Recipient.Followers = myNode.SelectSingleNode("followers_count") != null ? myNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundColor = myNode.SelectSingleNode("profile_background_color") != null ? myNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Recipient.ProfileTextColor = myNode.SelectSingleNode("profile_text_color") != null ? myNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Recipient.ProfileLinkColor = myNode.SelectSingleNode("profile_link_color") != null ? myNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarFillColor = myNode.SelectSingleNode("profile_sidebar_fill_color") != null ? myNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarBorderColor = myNode.SelectSingleNode("profile_sidebar_border_color") != null ? myNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Recipient.FriendsCount = myNode.SelectSingleNode("friends_count") != null ? myNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Recipient.UtcOffset = myNode.SelectSingleNode("utc_offset") != null ? myNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Recipient.TimeZone = myNode.SelectSingleNode("time_zone") != null ? myNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundImageUrl = myNode.SelectSingleNode("profile_background_image_url") != null ? myNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundTile = myNode.SelectSingleNode("profile_background_tile") != null ? myNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Recipient.StatusesCount = myNode.SelectSingleNode("statuses_count") != null ? myNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Recipient.Notifications = myNode.SelectSingleNode("notifications") != null ? myNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Recipient.Following = myNode.SelectSingleNode("following") != null ? myNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Recipient.Verified = myNode.SelectSingleNode("verified") != null ? myNode.SelectSingleNode("verified").InnerText : string.Empty;


                                sfArray.Add(dm);
                            }

                            break;
                        }
                    case Optional.MaxID:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/direct_messages.xml?max_id=" + optionalValue, xmlSettings);
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            foreach (XmlNode node in xmlDocument.SelectNodes("/direct-messages/direct_message"))
                            {
                                DirectMessage dm = new DirectMessage();

                                dm.ID = node.SelectSingleNode("id") != null ? node.SelectSingleNode("id").InnerText : string.Empty;
                                dm.SenderID = node.SelectSingleNode("sender_id") != null ? node.SelectSingleNode("sender_id").InnerText : string.Empty;
                                dm.Text = node.SelectSingleNode("text") != null ? node.SelectSingleNode("text").InnerText : string.Empty;
                                dm.RecipientID = node.SelectSingleNode("recipient_id") != null ? node.SelectSingleNode("recipient_id").InnerText : string.Empty;
                                dm.CreatedAt = node.SelectSingleNode("created_at") != null ? node.SelectSingleNode("created_at").InnerText : string.Empty;
                                dm.SenderScreenName = node.SelectSingleNode("sender_screen_name") != null ? node.SelectSingleNode("sender_screen_name").InnerText : string.Empty;
                                dm.RecipientScreenName = node.SelectSingleNode("recipient_screen_name") != null ? node.SelectSingleNode("recipient_screen_name").InnerText : string.Empty;

                                XmlNode sNode = node.SelectSingleNode("sender");

                                dm.Sender.ID = sNode.SelectSingleNode("id") != null ? sNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Sender.Name = sNode.SelectSingleNode("name") != null ? sNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Sender.ScreenName = sNode.SelectSingleNode("screen_name") != null ? sNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Sender.Location = sNode.SelectSingleNode("location") != null ? sNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Sender.Description = sNode.SelectSingleNode("description") != null ? sNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Sender.ProfileImageURL = sNode.SelectSingleNode("profile_image_url") != null ? sNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Sender.URL = sNode.SelectSingleNode("url") != null ? sNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Sender.Protected = sNode.SelectSingleNode("protected") != null ? sNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Sender.Followers = sNode.SelectSingleNode("followers_count") != null ? sNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundColor = sNode.SelectSingleNode("profile_background_color") != null ? sNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Sender.ProfileTextColor = sNode.SelectSingleNode("profile_text_color") != null ? sNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Sender.ProfileLinkColor = sNode.SelectSingleNode("profile_link_color") != null ? sNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarFillColor = sNode.SelectSingleNode("profile_sidebar_fill_color") != null ? sNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarBorderColor = sNode.SelectSingleNode("profile_sidebar_border_color") != null ? sNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Sender.FriendsCount = sNode.SelectSingleNode("friends_count") != null ? sNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Sender.UtcOffset = sNode.SelectSingleNode("utc_offset") != null ? sNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Sender.TimeZone = sNode.SelectSingleNode("time_zone") != null ? sNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundImageUrl = sNode.SelectSingleNode("profile_background_image_url") != null ? sNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundTile = sNode.SelectSingleNode("profile_background_tile") != null ? sNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Sender.StatusesCount = sNode.SelectSingleNode("statuses_count") != null ? sNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Sender.Notifications = sNode.SelectSingleNode("notifications") != null ? sNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Sender.Following = sNode.SelectSingleNode("following") != null ? sNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Sender.Verified = sNode.SelectSingleNode("verified") != null ? sNode.SelectSingleNode("verified").InnerText : string.Empty;


                                XmlNode myNode = node.SelectSingleNode("recipient");

                                dm.Recipient.ID = myNode.SelectSingleNode("id") != null ? myNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Recipient.Name = myNode.SelectSingleNode("name") != null ? myNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Recipient.ScreenName = myNode.SelectSingleNode("screen_name") != null ? myNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Recipient.Location = myNode.SelectSingleNode("location") != null ? myNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Recipient.Description = myNode.SelectSingleNode("description") != null ? myNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Recipient.ProfileImageURL = myNode.SelectSingleNode("profile_image_url") != null ? myNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Recipient.URL = myNode.SelectSingleNode("url") != null ? myNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Recipient.Protected = myNode.SelectSingleNode("protected") != null ? myNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Recipient.Followers = myNode.SelectSingleNode("followers_count") != null ? myNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundColor = myNode.SelectSingleNode("profile_background_color") != null ? myNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Recipient.ProfileTextColor = myNode.SelectSingleNode("profile_text_color") != null ? myNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Recipient.ProfileLinkColor = myNode.SelectSingleNode("profile_link_color") != null ? myNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarFillColor = myNode.SelectSingleNode("profile_sidebar_fill_color") != null ? myNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarBorderColor = myNode.SelectSingleNode("profile_sidebar_border_color") != null ? myNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Recipient.FriendsCount = myNode.SelectSingleNode("friends_count") != null ? myNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Recipient.UtcOffset = myNode.SelectSingleNode("utc_offset") != null ? myNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Recipient.TimeZone = myNode.SelectSingleNode("time_zone") != null ? myNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundImageUrl = myNode.SelectSingleNode("profile_background_image_url") != null ? myNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundTile = myNode.SelectSingleNode("profile_background_tile") != null ? myNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Recipient.StatusesCount = myNode.SelectSingleNode("statuses_count") != null ? myNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Recipient.Notifications = myNode.SelectSingleNode("notifications") != null ? myNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Recipient.Following = myNode.SelectSingleNode("following") != null ? myNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Recipient.Verified = myNode.SelectSingleNode("verified") != null ? myNode.SelectSingleNode("verified").InnerText : string.Empty;


                                sfArray.Add(dm);
                            }
                            break;
                        }
                    case Optional.None:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/direct_messages.xml", xmlSettings);
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            foreach (XmlNode node in xmlDocument.SelectNodes("/direct-messages/direct_message"))
                            {
                                DirectMessage dm = new DirectMessage();

                                dm.ID = node.SelectSingleNode("id") != null ? node.SelectSingleNode("id").InnerText : string.Empty;
                                dm.SenderID = node.SelectSingleNode("sender_id") != null ? node.SelectSingleNode("sender_id").InnerText : string.Empty;
                                dm.Text = node.SelectSingleNode("text") != null ? node.SelectSingleNode("text").InnerText : string.Empty;
                                dm.RecipientID = node.SelectSingleNode("recipient_id") != null ? node.SelectSingleNode("recipient_id").InnerText : string.Empty;
                                dm.CreatedAt = node.SelectSingleNode("created_at") != null ? node.SelectSingleNode("created_at").InnerText : string.Empty;
                                dm.SenderScreenName = node.SelectSingleNode("sender_screen_name") != null ? node.SelectSingleNode("sender_screen_name").InnerText : string.Empty;
                                dm.RecipientScreenName = node.SelectSingleNode("recipient_screen_name") != null ? node.SelectSingleNode("recipient_screen_name").InnerText : string.Empty;

                                XmlNode sNode = node.SelectSingleNode("sender");

                                dm.Sender.ID = sNode.SelectSingleNode("id") != null ? sNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Sender.Name = sNode.SelectSingleNode("name") != null ? sNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Sender.ScreenName = sNode.SelectSingleNode("screen_name") != null ? sNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Sender.Location = sNode.SelectSingleNode("location") != null ? sNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Sender.Description = sNode.SelectSingleNode("description") != null ? sNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Sender.ProfileImageURL = sNode.SelectSingleNode("profile_image_url") != null ? sNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Sender.URL = sNode.SelectSingleNode("url") != null ? sNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Sender.Protected = sNode.SelectSingleNode("protected") != null ? sNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Sender.Followers = sNode.SelectSingleNode("followers_count") != null ? sNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundColor = sNode.SelectSingleNode("profile_background_color") != null ? sNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Sender.ProfileTextColor = sNode.SelectSingleNode("profile_text_color") != null ? sNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Sender.ProfileLinkColor = sNode.SelectSingleNode("profile_link_color") != null ? sNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarFillColor = sNode.SelectSingleNode("profile_sidebar_fill_color") != null ? sNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarBorderColor = sNode.SelectSingleNode("profile_sidebar_border_color") != null ? sNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Sender.FriendsCount = sNode.SelectSingleNode("friends_count") != null ? sNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Sender.UtcOffset = sNode.SelectSingleNode("utc_offset") != null ? sNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Sender.TimeZone = sNode.SelectSingleNode("time_zone") != null ? sNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundImageUrl = sNode.SelectSingleNode("profile_background_image_url") != null ? sNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundTile = sNode.SelectSingleNode("profile_background_tile") != null ? sNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Sender.StatusesCount = sNode.SelectSingleNode("statuses_count") != null ? sNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Sender.Notifications = sNode.SelectSingleNode("notifications") != null ? sNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Sender.Following = sNode.SelectSingleNode("following") != null ? sNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Sender.Verified = sNode.SelectSingleNode("verified") != null ? sNode.SelectSingleNode("verified").InnerText : string.Empty;


                                XmlNode myNode = node.SelectSingleNode("recipient");

                                dm.Recipient.ID = myNode.SelectSingleNode("id") != null ? myNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Recipient.Name = myNode.SelectSingleNode("name") != null ? myNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Recipient.ScreenName = myNode.SelectSingleNode("screen_name") != null ? myNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Recipient.Location = myNode.SelectSingleNode("location") != null ? myNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Recipient.Description = myNode.SelectSingleNode("description") != null ? myNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Recipient.ProfileImageURL = myNode.SelectSingleNode("profile_image_url") != null ? myNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Recipient.URL = myNode.SelectSingleNode("url") != null ? myNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Recipient.Protected = myNode.SelectSingleNode("protected") != null ? myNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Recipient.Followers = myNode.SelectSingleNode("followers_count") != null ? myNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundColor = myNode.SelectSingleNode("profile_background_color") != null ? myNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Recipient.ProfileTextColor = myNode.SelectSingleNode("profile_text_color") != null ? myNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Recipient.ProfileLinkColor = myNode.SelectSingleNode("profile_link_color") != null ? myNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarFillColor = myNode.SelectSingleNode("profile_sidebar_fill_color") != null ? myNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarBorderColor = myNode.SelectSingleNode("profile_sidebar_border_color") != null ? myNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Recipient.FriendsCount = myNode.SelectSingleNode("friends_count") != null ? myNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Recipient.UtcOffset = myNode.SelectSingleNode("utc_offset") != null ? myNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Recipient.TimeZone = myNode.SelectSingleNode("time_zone") != null ? myNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundImageUrl = myNode.SelectSingleNode("profile_background_image_url") != null ? myNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundTile = myNode.SelectSingleNode("profile_background_tile") != null ? myNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Recipient.StatusesCount = myNode.SelectSingleNode("statuses_count") != null ? myNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Recipient.Notifications = myNode.SelectSingleNode("notifications") != null ? myNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Recipient.Following = myNode.SelectSingleNode("following") != null ? myNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Recipient.Verified = myNode.SelectSingleNode("verified") != null ? myNode.SelectSingleNode("verified").InnerText : string.Empty;


                                sfArray.Add(dm);
                            }
                            break;
                        }
                    case Optional.Page:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/direct_messages.xml?page=" + optionalValue, xmlSettings);
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            foreach (XmlNode node in xmlDocument.SelectNodes("/direct-messages/direct_message"))
                            {
                                DirectMessage dm = new DirectMessage();

                                dm.ID = node.SelectSingleNode("id") != null ? node.SelectSingleNode("id").InnerText : string.Empty;
                                dm.SenderID = node.SelectSingleNode("sender_id") != null ? node.SelectSingleNode("sender_id").InnerText : string.Empty;
                                dm.Text = node.SelectSingleNode("text") != null ? node.SelectSingleNode("text").InnerText : string.Empty;
                                dm.RecipientID = node.SelectSingleNode("recipient_id") != null ? node.SelectSingleNode("recipient_id").InnerText : string.Empty;
                                dm.CreatedAt = node.SelectSingleNode("created_at") != null ? node.SelectSingleNode("created_at").InnerText : string.Empty;
                                dm.SenderScreenName = node.SelectSingleNode("sender_screen_name") != null ? node.SelectSingleNode("sender_screen_name").InnerText : string.Empty;
                                dm.RecipientScreenName = node.SelectSingleNode("recipient_screen_name") != null ? node.SelectSingleNode("recipient_screen_name").InnerText : string.Empty;

                                XmlNode sNode = node.SelectSingleNode("sender");

                                dm.Sender.ID = sNode.SelectSingleNode("id") != null ? sNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Sender.Name = sNode.SelectSingleNode("name") != null ? sNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Sender.ScreenName = sNode.SelectSingleNode("screen_name") != null ? sNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Sender.Location = sNode.SelectSingleNode("location") != null ? sNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Sender.Description = sNode.SelectSingleNode("description") != null ? sNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Sender.ProfileImageURL = sNode.SelectSingleNode("profile_image_url") != null ? sNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Sender.URL = sNode.SelectSingleNode("url") != null ? sNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Sender.Protected = sNode.SelectSingleNode("protected") != null ? sNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Sender.Followers = sNode.SelectSingleNode("followers_count") != null ? sNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundColor = sNode.SelectSingleNode("profile_background_color") != null ? sNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Sender.ProfileTextColor = sNode.SelectSingleNode("profile_text_color") != null ? sNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Sender.ProfileLinkColor = sNode.SelectSingleNode("profile_link_color") != null ? sNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarFillColor = sNode.SelectSingleNode("profile_sidebar_fill_color") != null ? sNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarBorderColor = sNode.SelectSingleNode("profile_sidebar_border_color") != null ? sNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Sender.FriendsCount = sNode.SelectSingleNode("friends_count") != null ? sNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Sender.UtcOffset = sNode.SelectSingleNode("utc_offset") != null ? sNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Sender.TimeZone = sNode.SelectSingleNode("time_zone") != null ? sNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundImageUrl = sNode.SelectSingleNode("profile_background_image_url") != null ? sNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundTile = sNode.SelectSingleNode("profile_background_tile") != null ? sNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Sender.StatusesCount = sNode.SelectSingleNode("statuses_count") != null ? sNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Sender.Notifications = sNode.SelectSingleNode("notifications") != null ? sNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Sender.Following = sNode.SelectSingleNode("following") != null ? sNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Sender.Verified = sNode.SelectSingleNode("verified") != null ? sNode.SelectSingleNode("verified").InnerText : string.Empty;


                                XmlNode myNode = node.SelectSingleNode("recipient");

                                dm.Recipient.ID = myNode.SelectSingleNode("id") != null ? myNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Recipient.Name = myNode.SelectSingleNode("name") != null ? myNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Recipient.ScreenName = myNode.SelectSingleNode("screen_name") != null ? myNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Recipient.Location = myNode.SelectSingleNode("location") != null ? myNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Recipient.Description = myNode.SelectSingleNode("description") != null ? myNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Recipient.ProfileImageURL = myNode.SelectSingleNode("profile_image_url") != null ? myNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Recipient.URL = myNode.SelectSingleNode("url") != null ? myNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Recipient.Protected = myNode.SelectSingleNode("protected") != null ? myNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Recipient.Followers = myNode.SelectSingleNode("followers_count") != null ? myNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundColor = myNode.SelectSingleNode("profile_background_color") != null ? myNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Recipient.ProfileTextColor = myNode.SelectSingleNode("profile_text_color") != null ? myNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Recipient.ProfileLinkColor = myNode.SelectSingleNode("profile_link_color") != null ? myNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarFillColor = myNode.SelectSingleNode("profile_sidebar_fill_color") != null ? myNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarBorderColor = myNode.SelectSingleNode("profile_sidebar_border_color") != null ? myNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Recipient.FriendsCount = myNode.SelectSingleNode("friends_count") != null ? myNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Recipient.UtcOffset = myNode.SelectSingleNode("utc_offset") != null ? myNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Recipient.TimeZone = myNode.SelectSingleNode("time_zone") != null ? myNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundImageUrl = myNode.SelectSingleNode("profile_background_image_url") != null ? myNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundTile = myNode.SelectSingleNode("profile_background_tile") != null ? myNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Recipient.StatusesCount = myNode.SelectSingleNode("statuses_count") != null ? myNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Recipient.Notifications = myNode.SelectSingleNode("notifications") != null ? myNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Recipient.Following = myNode.SelectSingleNode("following") != null ? myNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Recipient.Verified = myNode.SelectSingleNode("verified") != null ? myNode.SelectSingleNode("verified").InnerText : string.Empty;


                                sfArray.Add(dm);
                            }
                            break;
                        }
                    case Optional.SinceID:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/direct_messages.xml?since_id=" + optionalValue, xmlSettings);
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            foreach (XmlNode node in xmlDocument.SelectNodes("/direct-messages/direct_message"))
                            {
                                DirectMessage dm = new DirectMessage();

                                dm.ID = node.SelectSingleNode("id") != null ? node.SelectSingleNode("id").InnerText : string.Empty;
                                dm.SenderID = node.SelectSingleNode("sender_id") != null ? node.SelectSingleNode("sender_id").InnerText : string.Empty;
                                dm.Text = node.SelectSingleNode("text") != null ? node.SelectSingleNode("text").InnerText : string.Empty;
                                dm.RecipientID = node.SelectSingleNode("recipient_id") != null ? node.SelectSingleNode("recipient_id").InnerText : string.Empty;
                                dm.CreatedAt = node.SelectSingleNode("created_at") != null ? node.SelectSingleNode("created_at").InnerText : string.Empty;
                                dm.SenderScreenName = node.SelectSingleNode("sender_screen_name") != null ? node.SelectSingleNode("sender_screen_name").InnerText : string.Empty;
                                dm.RecipientScreenName = node.SelectSingleNode("recipient_screen_name") != null ? node.SelectSingleNode("recipient_screen_name").InnerText : string.Empty;

                                XmlNode sNode = node.SelectSingleNode("sender");

                                dm.Sender.ID = sNode.SelectSingleNode("id") != null ? sNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Sender.Name = sNode.SelectSingleNode("name") != null ? sNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Sender.ScreenName = sNode.SelectSingleNode("screen_name") != null ? sNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Sender.Location = sNode.SelectSingleNode("location") != null ? sNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Sender.Description = sNode.SelectSingleNode("description") != null ? sNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Sender.ProfileImageURL = sNode.SelectSingleNode("profile_image_url") != null ? sNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Sender.URL = sNode.SelectSingleNode("url") != null ? sNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Sender.Protected = sNode.SelectSingleNode("protected") != null ? sNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Sender.Followers = sNode.SelectSingleNode("followers_count") != null ? sNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundColor = sNode.SelectSingleNode("profile_background_color") != null ? sNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Sender.ProfileTextColor = sNode.SelectSingleNode("profile_text_color") != null ? sNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Sender.ProfileLinkColor = sNode.SelectSingleNode("profile_link_color") != null ? sNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarFillColor = sNode.SelectSingleNode("profile_sidebar_fill_color") != null ? sNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarBorderColor = sNode.SelectSingleNode("profile_sidebar_border_color") != null ? sNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Sender.FriendsCount = sNode.SelectSingleNode("friends_count") != null ? sNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Sender.UtcOffset = sNode.SelectSingleNode("utc_offset") != null ? sNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Sender.TimeZone = sNode.SelectSingleNode("time_zone") != null ? sNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundImageUrl = sNode.SelectSingleNode("profile_background_image_url") != null ? sNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundTile = sNode.SelectSingleNode("profile_background_tile") != null ? sNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Sender.StatusesCount = sNode.SelectSingleNode("statuses_count") != null ? sNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Sender.Notifications = sNode.SelectSingleNode("notifications") != null ? sNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Sender.Following = sNode.SelectSingleNode("following") != null ? sNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Sender.Verified = sNode.SelectSingleNode("verified") != null ? sNode.SelectSingleNode("verified").InnerText : string.Empty;


                                XmlNode myNode = node.SelectSingleNode("recipient");

                                dm.Recipient.ID = myNode.SelectSingleNode("id") != null ? myNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Recipient.Name = myNode.SelectSingleNode("name") != null ? myNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Recipient.ScreenName = myNode.SelectSingleNode("screen_name") != null ? myNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Recipient.Location = myNode.SelectSingleNode("location") != null ? myNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Recipient.Description = myNode.SelectSingleNode("description") != null ? myNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Recipient.ProfileImageURL = myNode.SelectSingleNode("profile_image_url") != null ? myNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Recipient.URL = myNode.SelectSingleNode("url") != null ? myNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Recipient.Protected = myNode.SelectSingleNode("protected") != null ? myNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Recipient.Followers = myNode.SelectSingleNode("followers_count") != null ? myNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundColor = myNode.SelectSingleNode("profile_background_color") != null ? myNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Recipient.ProfileTextColor = myNode.SelectSingleNode("profile_text_color") != null ? myNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Recipient.ProfileLinkColor = myNode.SelectSingleNode("profile_link_color") != null ? myNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarFillColor = myNode.SelectSingleNode("profile_sidebar_fill_color") != null ? myNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarBorderColor = myNode.SelectSingleNode("profile_sidebar_border_color") != null ? myNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Recipient.FriendsCount = myNode.SelectSingleNode("friends_count") != null ? myNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Recipient.UtcOffset = myNode.SelectSingleNode("utc_offset") != null ? myNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Recipient.TimeZone = myNode.SelectSingleNode("time_zone") != null ? myNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundImageUrl = myNode.SelectSingleNode("profile_background_image_url") != null ? myNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundTile = myNode.SelectSingleNode("profile_background_tile") != null ? myNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Recipient.StatusesCount = myNode.SelectSingleNode("statuses_count") != null ? myNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Recipient.Notifications = myNode.SelectSingleNode("notifications") != null ? myNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Recipient.Following = myNode.SelectSingleNode("following") != null ? myNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Recipient.Verified = myNode.SelectSingleNode("verified") != null ? myNode.SelectSingleNode("verified").InnerText : string.Empty;


                                sfArray.Add(dm);
                            }
                            break;
                        }
                }
                return sfArray;
            }
            catch
            {
                return null;
            }
        }
        #endregion

        #region Direct Messages / Sent

        /// <summary>
        /// Returns a list of the 20 most recent direct messages
        /// sent by the authenticating user.  The XML and JSON 
        /// versions include detailed information about the sending
        /// and recipient users.
        /// http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-direct_messages%C2%A0sent
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        /// <param name="optional">Message display parameter (required).</param>
        /// <param name="optionalValue">Optional parameter value (required).</param>

        public static ArrayList Direct_Message_Sent(string username, string password, Optional optional, string optionalValue)
        {
            try
            {
                ArrayList sfArray = new ArrayList();

                XmlUrlResolver xmlResolver = new XmlUrlResolver();
                xmlResolver.Credentials = new NetworkCredential(username, password);

                XmlReaderSettings xmlSettings = new XmlReaderSettings();
                xmlSettings.XmlResolver = xmlResolver;

                switch (optional)
                {
                    case Optional.Count:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/direct_messages/sent.xml?count=" + optionalValue, xmlSettings);
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            foreach (XmlNode node in xmlDocument.SelectNodes("/direct-messages/direct_message"))
                            {
                                DirectMessage dm = new DirectMessage();

                                dm.ID = node.SelectSingleNode("id") != null ? node.SelectSingleNode("id").InnerText : string.Empty;
                                dm.SenderID = node.SelectSingleNode("sender_id") != null ? node.SelectSingleNode("sender_id").InnerText : string.Empty;
                                dm.Text = node.SelectSingleNode("text") != null ? node.SelectSingleNode("text").InnerText : string.Empty;
                                dm.RecipientID = node.SelectSingleNode("recipient_id") != null ? node.SelectSingleNode("recipient_id").InnerText : string.Empty;
                                dm.CreatedAt = node.SelectSingleNode("created_at") != null ? node.SelectSingleNode("created_at").InnerText : string.Empty;
                                dm.SenderScreenName = node.SelectSingleNode("sender_screen_name") != null ? node.SelectSingleNode("sender_screen_name").InnerText : string.Empty;
                                dm.RecipientScreenName = node.SelectSingleNode("recipient_screen_name") != null ? node.SelectSingleNode("recipient_screen_name").InnerText : string.Empty;

                                XmlNode sNode = node.SelectSingleNode("sender");

                                dm.Sender.ID = sNode.SelectSingleNode("id") != null ? sNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Sender.Name = sNode.SelectSingleNode("name") != null ? sNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Sender.ScreenName = sNode.SelectSingleNode("screen_name") != null ? sNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Sender.Location = sNode.SelectSingleNode("location") != null ? sNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Sender.Description = sNode.SelectSingleNode("description") != null ? sNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Sender.ProfileImageURL = sNode.SelectSingleNode("profile_image_url") != null ? sNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Sender.URL = sNode.SelectSingleNode("url") != null ? sNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Sender.Protected = sNode.SelectSingleNode("protected") != null ? sNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Sender.Followers = sNode.SelectSingleNode("followers_count") != null ? sNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundColor = sNode.SelectSingleNode("profile_background_color") != null ? sNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Sender.ProfileTextColor = sNode.SelectSingleNode("profile_text_color") != null ? sNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Sender.ProfileLinkColor = sNode.SelectSingleNode("profile_link_color") != null ? sNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarFillColor = sNode.SelectSingleNode("profile_sidebar_fill_color") != null ? sNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarBorderColor = sNode.SelectSingleNode("profile_sidebar_border_color") != null ? sNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Sender.FriendsCount = sNode.SelectSingleNode("friends_count") != null ? sNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Sender.UtcOffset = sNode.SelectSingleNode("utc_offset") != null ? sNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Sender.TimeZone = sNode.SelectSingleNode("time_zone") != null ? sNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundImageUrl = sNode.SelectSingleNode("profile_background_image_url") != null ? sNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundTile = sNode.SelectSingleNode("profile_background_tile") != null ? sNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Sender.StatusesCount = sNode.SelectSingleNode("statuses_count") != null ? sNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Sender.Notifications = sNode.SelectSingleNode("notifications") != null ? sNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Sender.Following = sNode.SelectSingleNode("following") != null ? sNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Sender.Verified = sNode.SelectSingleNode("verified") != null ? sNode.SelectSingleNode("verified").InnerText : string.Empty;


                                XmlNode myNode = node.SelectSingleNode("recipient");

                                dm.Recipient.ID = myNode.SelectSingleNode("id") != null ? myNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Recipient.Name = myNode.SelectSingleNode("name") != null ? myNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Recipient.ScreenName = myNode.SelectSingleNode("screen_name") != null ? myNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Recipient.Location = myNode.SelectSingleNode("location") != null ? myNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Recipient.Description = myNode.SelectSingleNode("description") != null ? myNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Recipient.ProfileImageURL = myNode.SelectSingleNode("profile_image_url") != null ? myNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Recipient.URL = myNode.SelectSingleNode("url") != null ? myNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Recipient.Protected = myNode.SelectSingleNode("protected") != null ? myNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Recipient.Followers = myNode.SelectSingleNode("followers_count") != null ? myNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundColor = myNode.SelectSingleNode("profile_background_color") != null ? myNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Recipient.ProfileTextColor = myNode.SelectSingleNode("profile_text_color") != null ? myNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Recipient.ProfileLinkColor = myNode.SelectSingleNode("profile_link_color") != null ? myNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarFillColor = myNode.SelectSingleNode("profile_sidebar_fill_color") != null ? myNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarBorderColor = myNode.SelectSingleNode("profile_sidebar_border_color") != null ? myNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Recipient.FriendsCount = myNode.SelectSingleNode("friends_count") != null ? myNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Recipient.UtcOffset = myNode.SelectSingleNode("utc_offset") != null ? myNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Recipient.TimeZone = myNode.SelectSingleNode("time_zone") != null ? myNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundImageUrl = myNode.SelectSingleNode("profile_background_image_url") != null ? myNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundTile = myNode.SelectSingleNode("profile_background_tile") != null ? myNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Recipient.StatusesCount = myNode.SelectSingleNode("statuses_count") != null ? myNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Recipient.Notifications = myNode.SelectSingleNode("notifications") != null ? myNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Recipient.Following = myNode.SelectSingleNode("following") != null ? myNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Recipient.Verified = myNode.SelectSingleNode("verified") != null ? myNode.SelectSingleNode("verified").InnerText : string.Empty;


                                sfArray.Add(dm);
                            }

                            break;
                        }
                    case Optional.MaxID:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/direct_messages/sent.xml?max_id=" + optionalValue, xmlSettings);
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            foreach (XmlNode node in xmlDocument.SelectNodes("/direct-messages/direct_message"))
                            {
                                DirectMessage dm = new DirectMessage();

                                dm.ID = node.SelectSingleNode("id") != null ? node.SelectSingleNode("id").InnerText : string.Empty;
                                dm.SenderID = node.SelectSingleNode("sender_id") != null ? node.SelectSingleNode("sender_id").InnerText : string.Empty;
                                dm.Text = node.SelectSingleNode("text") != null ? node.SelectSingleNode("text").InnerText : string.Empty;
                                dm.RecipientID = node.SelectSingleNode("recipient_id") != null ? node.SelectSingleNode("recipient_id").InnerText : string.Empty;
                                dm.CreatedAt = node.SelectSingleNode("created_at") != null ? node.SelectSingleNode("created_at").InnerText : string.Empty;
                                dm.SenderScreenName = node.SelectSingleNode("sender_screen_name") != null ? node.SelectSingleNode("sender_screen_name").InnerText : string.Empty;
                                dm.RecipientScreenName = node.SelectSingleNode("recipient_screen_name") != null ? node.SelectSingleNode("recipient_screen_name").InnerText : string.Empty;

                                XmlNode sNode = node.SelectSingleNode("sender");

                                dm.Sender.ID = sNode.SelectSingleNode("id") != null ? sNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Sender.Name = sNode.SelectSingleNode("name") != null ? sNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Sender.ScreenName = sNode.SelectSingleNode("screen_name") != null ? sNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Sender.Location = sNode.SelectSingleNode("location") != null ? sNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Sender.Description = sNode.SelectSingleNode("description") != null ? sNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Sender.ProfileImageURL = sNode.SelectSingleNode("profile_image_url") != null ? sNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Sender.URL = sNode.SelectSingleNode("url") != null ? sNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Sender.Protected = sNode.SelectSingleNode("protected") != null ? sNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Sender.Followers = sNode.SelectSingleNode("followers_count") != null ? sNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundColor = sNode.SelectSingleNode("profile_background_color") != null ? sNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Sender.ProfileTextColor = sNode.SelectSingleNode("profile_text_color") != null ? sNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Sender.ProfileLinkColor = sNode.SelectSingleNode("profile_link_color") != null ? sNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarFillColor = sNode.SelectSingleNode("profile_sidebar_fill_color") != null ? sNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarBorderColor = sNode.SelectSingleNode("profile_sidebar_border_color") != null ? sNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Sender.FriendsCount = sNode.SelectSingleNode("friends_count") != null ? sNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Sender.UtcOffset = sNode.SelectSingleNode("utc_offset") != null ? sNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Sender.TimeZone = sNode.SelectSingleNode("time_zone") != null ? sNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundImageUrl = sNode.SelectSingleNode("profile_background_image_url") != null ? sNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundTile = sNode.SelectSingleNode("profile_background_tile") != null ? sNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Sender.StatusesCount = sNode.SelectSingleNode("statuses_count") != null ? sNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Sender.Notifications = sNode.SelectSingleNode("notifications") != null ? sNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Sender.Following = sNode.SelectSingleNode("following") != null ? sNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Sender.Verified = sNode.SelectSingleNode("verified") != null ? sNode.SelectSingleNode("verified").InnerText : string.Empty;


                                XmlNode myNode = node.SelectSingleNode("recipient");

                                dm.Recipient.ID = myNode.SelectSingleNode("id") != null ? myNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Recipient.Name = myNode.SelectSingleNode("name") != null ? myNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Recipient.ScreenName = myNode.SelectSingleNode("screen_name") != null ? myNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Recipient.Location = myNode.SelectSingleNode("location") != null ? myNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Recipient.Description = myNode.SelectSingleNode("description") != null ? myNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Recipient.ProfileImageURL = myNode.SelectSingleNode("profile_image_url") != null ? myNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Recipient.URL = myNode.SelectSingleNode("url") != null ? myNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Recipient.Protected = myNode.SelectSingleNode("protected") != null ? myNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Recipient.Followers = myNode.SelectSingleNode("followers_count") != null ? myNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundColor = myNode.SelectSingleNode("profile_background_color") != null ? myNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Recipient.ProfileTextColor = myNode.SelectSingleNode("profile_text_color") != null ? myNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Recipient.ProfileLinkColor = myNode.SelectSingleNode("profile_link_color") != null ? myNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarFillColor = myNode.SelectSingleNode("profile_sidebar_fill_color") != null ? myNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarBorderColor = myNode.SelectSingleNode("profile_sidebar_border_color") != null ? myNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Recipient.FriendsCount = myNode.SelectSingleNode("friends_count") != null ? myNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Recipient.UtcOffset = myNode.SelectSingleNode("utc_offset") != null ? myNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Recipient.TimeZone = myNode.SelectSingleNode("time_zone") != null ? myNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundImageUrl = myNode.SelectSingleNode("profile_background_image_url") != null ? myNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundTile = myNode.SelectSingleNode("profile_background_tile") != null ? myNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Recipient.StatusesCount = myNode.SelectSingleNode("statuses_count") != null ? myNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Recipient.Notifications = myNode.SelectSingleNode("notifications") != null ? myNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Recipient.Following = myNode.SelectSingleNode("following") != null ? myNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Recipient.Verified = myNode.SelectSingleNode("verified") != null ? myNode.SelectSingleNode("verified").InnerText : string.Empty;


                                sfArray.Add(dm);
                            }
                            break;
                        }
                    case Optional.None:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/direct_messages/sent.xml", xmlSettings);
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            foreach (XmlNode node in xmlDocument.SelectNodes("/direct-messages/direct_message"))
                            {
                                DirectMessage dm = new DirectMessage();

                                dm.ID = node.SelectSingleNode("id") != null ? node.SelectSingleNode("id").InnerText : string.Empty;
                                dm.SenderID = node.SelectSingleNode("sender_id") != null ? node.SelectSingleNode("sender_id").InnerText : string.Empty;
                                dm.Text = node.SelectSingleNode("text") != null ? node.SelectSingleNode("text").InnerText : string.Empty;
                                dm.RecipientID = node.SelectSingleNode("recipient_id") != null ? node.SelectSingleNode("recipient_id").InnerText : string.Empty;
                                dm.CreatedAt = node.SelectSingleNode("created_at") != null ? node.SelectSingleNode("created_at").InnerText : string.Empty;
                                dm.SenderScreenName = node.SelectSingleNode("sender_screen_name") != null ? node.SelectSingleNode("sender_screen_name").InnerText : string.Empty;
                                dm.RecipientScreenName = node.SelectSingleNode("recipient_screen_name") != null ? node.SelectSingleNode("recipient_screen_name").InnerText : string.Empty;

                                XmlNode sNode = node.SelectSingleNode("sender");

                                dm.Sender.ID = sNode.SelectSingleNode("id") != null ? sNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Sender.Name = sNode.SelectSingleNode("name") != null ? sNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Sender.ScreenName = sNode.SelectSingleNode("screen_name") != null ? sNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Sender.Location = sNode.SelectSingleNode("location") != null ? sNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Sender.Description = sNode.SelectSingleNode("description") != null ? sNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Sender.ProfileImageURL = sNode.SelectSingleNode("profile_image_url") != null ? sNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Sender.URL = sNode.SelectSingleNode("url") != null ? sNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Sender.Protected = sNode.SelectSingleNode("protected") != null ? sNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Sender.Followers = sNode.SelectSingleNode("followers_count") != null ? sNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundColor = sNode.SelectSingleNode("profile_background_color") != null ? sNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Sender.ProfileTextColor = sNode.SelectSingleNode("profile_text_color") != null ? sNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Sender.ProfileLinkColor = sNode.SelectSingleNode("profile_link_color") != null ? sNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarFillColor = sNode.SelectSingleNode("profile_sidebar_fill_color") != null ? sNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarBorderColor = sNode.SelectSingleNode("profile_sidebar_border_color") != null ? sNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Sender.FriendsCount = sNode.SelectSingleNode("friends_count") != null ? sNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Sender.UtcOffset = sNode.SelectSingleNode("utc_offset") != null ? sNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Sender.TimeZone = sNode.SelectSingleNode("time_zone") != null ? sNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundImageUrl = sNode.SelectSingleNode("profile_background_image_url") != null ? sNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundTile = sNode.SelectSingleNode("profile_background_tile") != null ? sNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Sender.StatusesCount = sNode.SelectSingleNode("statuses_count") != null ? sNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Sender.Notifications = sNode.SelectSingleNode("notifications") != null ? sNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Sender.Following = sNode.SelectSingleNode("following") != null ? sNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Sender.Verified = sNode.SelectSingleNode("verified") != null ? sNode.SelectSingleNode("verified").InnerText : string.Empty;


                                XmlNode myNode = node.SelectSingleNode("recipient");

                                dm.Recipient.ID = myNode.SelectSingleNode("id") != null ? myNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Recipient.Name = myNode.SelectSingleNode("name") != null ? myNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Recipient.ScreenName = myNode.SelectSingleNode("screen_name") != null ? myNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Recipient.Location = myNode.SelectSingleNode("location") != null ? myNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Recipient.Description = myNode.SelectSingleNode("description") != null ? myNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Recipient.ProfileImageURL = myNode.SelectSingleNode("profile_image_url") != null ? myNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Recipient.URL = myNode.SelectSingleNode("url") != null ? myNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Recipient.Protected = myNode.SelectSingleNode("protected") != null ? myNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Recipient.Followers = myNode.SelectSingleNode("followers_count") != null ? myNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundColor = myNode.SelectSingleNode("profile_background_color") != null ? myNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Recipient.ProfileTextColor = myNode.SelectSingleNode("profile_text_color") != null ? myNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Recipient.ProfileLinkColor = myNode.SelectSingleNode("profile_link_color") != null ? myNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarFillColor = myNode.SelectSingleNode("profile_sidebar_fill_color") != null ? myNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarBorderColor = myNode.SelectSingleNode("profile_sidebar_border_color") != null ? myNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Recipient.FriendsCount = myNode.SelectSingleNode("friends_count") != null ? myNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Recipient.UtcOffset = myNode.SelectSingleNode("utc_offset") != null ? myNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Recipient.TimeZone = myNode.SelectSingleNode("time_zone") != null ? myNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundImageUrl = myNode.SelectSingleNode("profile_background_image_url") != null ? myNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundTile = myNode.SelectSingleNode("profile_background_tile") != null ? myNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Recipient.StatusesCount = myNode.SelectSingleNode("statuses_count") != null ? myNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Recipient.Notifications = myNode.SelectSingleNode("notifications") != null ? myNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Recipient.Following = myNode.SelectSingleNode("following") != null ? myNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Recipient.Verified = myNode.SelectSingleNode("verified") != null ? myNode.SelectSingleNode("verified").InnerText : string.Empty;


                                sfArray.Add(dm);
                            }
                            break;
                        }
                    case Optional.Page:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/direct_messages/sent.xml?page=" + optionalValue, xmlSettings);
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            foreach (XmlNode node in xmlDocument.SelectNodes("/direct-messages/direct_message"))
                            {
                                DirectMessage dm = new DirectMessage();

                                dm.ID = node.SelectSingleNode("id") != null ? node.SelectSingleNode("id").InnerText : string.Empty;
                                dm.SenderID = node.SelectSingleNode("sender_id") != null ? node.SelectSingleNode("sender_id").InnerText : string.Empty;
                                dm.Text = node.SelectSingleNode("text") != null ? node.SelectSingleNode("text").InnerText : string.Empty;
                                dm.RecipientID = node.SelectSingleNode("recipient_id") != null ? node.SelectSingleNode("recipient_id").InnerText : string.Empty;
                                dm.CreatedAt = node.SelectSingleNode("created_at") != null ? node.SelectSingleNode("created_at").InnerText : string.Empty;
                                dm.SenderScreenName = node.SelectSingleNode("sender_screen_name") != null ? node.SelectSingleNode("sender_screen_name").InnerText : string.Empty;
                                dm.RecipientScreenName = node.SelectSingleNode("recipient_screen_name") != null ? node.SelectSingleNode("recipient_screen_name").InnerText : string.Empty;

                                XmlNode sNode = node.SelectSingleNode("sender");

                                dm.Sender.ID = sNode.SelectSingleNode("id") != null ? sNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Sender.Name = sNode.SelectSingleNode("name") != null ? sNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Sender.ScreenName = sNode.SelectSingleNode("screen_name") != null ? sNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Sender.Location = sNode.SelectSingleNode("location") != null ? sNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Sender.Description = sNode.SelectSingleNode("description") != null ? sNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Sender.ProfileImageURL = sNode.SelectSingleNode("profile_image_url") != null ? sNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Sender.URL = sNode.SelectSingleNode("url") != null ? sNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Sender.Protected = sNode.SelectSingleNode("protected") != null ? sNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Sender.Followers = sNode.SelectSingleNode("followers_count") != null ? sNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundColor = sNode.SelectSingleNode("profile_background_color") != null ? sNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Sender.ProfileTextColor = sNode.SelectSingleNode("profile_text_color") != null ? sNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Sender.ProfileLinkColor = sNode.SelectSingleNode("profile_link_color") != null ? sNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarFillColor = sNode.SelectSingleNode("profile_sidebar_fill_color") != null ? sNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarBorderColor = sNode.SelectSingleNode("profile_sidebar_border_color") != null ? sNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Sender.FriendsCount = sNode.SelectSingleNode("friends_count") != null ? sNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Sender.UtcOffset = sNode.SelectSingleNode("utc_offset") != null ? sNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Sender.TimeZone = sNode.SelectSingleNode("time_zone") != null ? sNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundImageUrl = sNode.SelectSingleNode("profile_background_image_url") != null ? sNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundTile = sNode.SelectSingleNode("profile_background_tile") != null ? sNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Sender.StatusesCount = sNode.SelectSingleNode("statuses_count") != null ? sNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Sender.Notifications = sNode.SelectSingleNode("notifications") != null ? sNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Sender.Following = sNode.SelectSingleNode("following") != null ? sNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Sender.Verified = sNode.SelectSingleNode("verified") != null ? sNode.SelectSingleNode("verified").InnerText : string.Empty;


                                XmlNode myNode = node.SelectSingleNode("recipient");

                                dm.Recipient.ID = myNode.SelectSingleNode("id") != null ? myNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Recipient.Name = myNode.SelectSingleNode("name") != null ? myNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Recipient.ScreenName = myNode.SelectSingleNode("screen_name") != null ? myNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Recipient.Location = myNode.SelectSingleNode("location") != null ? myNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Recipient.Description = myNode.SelectSingleNode("description") != null ? myNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Recipient.ProfileImageURL = myNode.SelectSingleNode("profile_image_url") != null ? myNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Recipient.URL = myNode.SelectSingleNode("url") != null ? myNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Recipient.Protected = myNode.SelectSingleNode("protected") != null ? myNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Recipient.Followers = myNode.SelectSingleNode("followers_count") != null ? myNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundColor = myNode.SelectSingleNode("profile_background_color") != null ? myNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Recipient.ProfileTextColor = myNode.SelectSingleNode("profile_text_color") != null ? myNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Recipient.ProfileLinkColor = myNode.SelectSingleNode("profile_link_color") != null ? myNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarFillColor = myNode.SelectSingleNode("profile_sidebar_fill_color") != null ? myNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarBorderColor = myNode.SelectSingleNode("profile_sidebar_border_color") != null ? myNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Recipient.FriendsCount = myNode.SelectSingleNode("friends_count") != null ? myNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Recipient.UtcOffset = myNode.SelectSingleNode("utc_offset") != null ? myNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Recipient.TimeZone = myNode.SelectSingleNode("time_zone") != null ? myNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundImageUrl = myNode.SelectSingleNode("profile_background_image_url") != null ? myNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundTile = myNode.SelectSingleNode("profile_background_tile") != null ? myNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Recipient.StatusesCount = myNode.SelectSingleNode("statuses_count") != null ? myNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Recipient.Notifications = myNode.SelectSingleNode("notifications") != null ? myNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Recipient.Following = myNode.SelectSingleNode("following") != null ? myNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Recipient.Verified = myNode.SelectSingleNode("verified") != null ? myNode.SelectSingleNode("verified").InnerText : string.Empty;


                                sfArray.Add(dm);
                            }
                            break;
                        }
                    case Optional.SinceID:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/direct_messages/sent.xml?since_id=" + optionalValue, xmlSettings);
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            foreach (XmlNode node in xmlDocument.SelectNodes("/direct-messages/direct_message"))
                            {
                                DirectMessage dm = new DirectMessage();

                                dm.ID = node.SelectSingleNode("id") != null ? node.SelectSingleNode("id").InnerText : string.Empty;
                                dm.SenderID = node.SelectSingleNode("sender_id") != null ? node.SelectSingleNode("sender_id").InnerText : string.Empty;
                                dm.Text = node.SelectSingleNode("text") != null ? node.SelectSingleNode("text").InnerText : string.Empty;
                                dm.RecipientID = node.SelectSingleNode("recipient_id") != null ? node.SelectSingleNode("recipient_id").InnerText : string.Empty;
                                dm.CreatedAt = node.SelectSingleNode("created_at") != null ? node.SelectSingleNode("created_at").InnerText : string.Empty;
                                dm.SenderScreenName = node.SelectSingleNode("sender_screen_name") != null ? node.SelectSingleNode("sender_screen_name").InnerText : string.Empty;
                                dm.RecipientScreenName = node.SelectSingleNode("recipient_screen_name") != null ? node.SelectSingleNode("recipient_screen_name").InnerText : string.Empty;

                                XmlNode sNode = node.SelectSingleNode("sender");

                                dm.Sender.ID = sNode.SelectSingleNode("id") != null ? sNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Sender.Name = sNode.SelectSingleNode("name") != null ? sNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Sender.ScreenName = sNode.SelectSingleNode("screen_name") != null ? sNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Sender.Location = sNode.SelectSingleNode("location") != null ? sNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Sender.Description = sNode.SelectSingleNode("description") != null ? sNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Sender.ProfileImageURL = sNode.SelectSingleNode("profile_image_url") != null ? sNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Sender.URL = sNode.SelectSingleNode("url") != null ? sNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Sender.Protected = sNode.SelectSingleNode("protected") != null ? sNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Sender.Followers = sNode.SelectSingleNode("followers_count") != null ? sNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundColor = sNode.SelectSingleNode("profile_background_color") != null ? sNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Sender.ProfileTextColor = sNode.SelectSingleNode("profile_text_color") != null ? sNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Sender.ProfileLinkColor = sNode.SelectSingleNode("profile_link_color") != null ? sNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarFillColor = sNode.SelectSingleNode("profile_sidebar_fill_color") != null ? sNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Sender.ProfileSidebarBorderColor = sNode.SelectSingleNode("profile_sidebar_border_color") != null ? sNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Sender.FriendsCount = sNode.SelectSingleNode("friends_count") != null ? sNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Sender.UtcOffset = sNode.SelectSingleNode("utc_offset") != null ? sNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Sender.TimeZone = sNode.SelectSingleNode("time_zone") != null ? sNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundImageUrl = sNode.SelectSingleNode("profile_background_image_url") != null ? sNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Sender.ProfileBackgroundTile = sNode.SelectSingleNode("profile_background_tile") != null ? sNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Sender.StatusesCount = sNode.SelectSingleNode("statuses_count") != null ? sNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Sender.Notifications = sNode.SelectSingleNode("notifications") != null ? sNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Sender.Following = sNode.SelectSingleNode("following") != null ? sNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Sender.Verified = sNode.SelectSingleNode("verified") != null ? sNode.SelectSingleNode("verified").InnerText : string.Empty;


                                XmlNode myNode = node.SelectSingleNode("recipient");

                                dm.Recipient.ID = myNode.SelectSingleNode("id") != null ? myNode.SelectSingleNode("id").InnerText : string.Empty;
                                dm.Recipient.Name = myNode.SelectSingleNode("name") != null ? myNode.SelectSingleNode("name").InnerText : string.Empty;
                                dm.Recipient.ScreenName = myNode.SelectSingleNode("screen_name") != null ? myNode.SelectSingleNode("screen_name").InnerText : string.Empty;
                                dm.Recipient.Location = myNode.SelectSingleNode("location") != null ? myNode.SelectSingleNode("location").InnerText : string.Empty;
                                dm.Recipient.Description = myNode.SelectSingleNode("description") != null ? myNode.SelectSingleNode("description").InnerText : string.Empty;
                                dm.Recipient.ProfileImageURL = myNode.SelectSingleNode("profile_image_url") != null ? myNode.SelectSingleNode("profile_image_url").InnerText : string.Empty;
                                dm.Recipient.URL = myNode.SelectSingleNode("url") != null ? myNode.SelectSingleNode("url").InnerText : string.Empty;
                                dm.Recipient.Protected = myNode.SelectSingleNode("protected") != null ? myNode.SelectSingleNode("protected").InnerText : string.Empty;
                                dm.Recipient.Followers = myNode.SelectSingleNode("followers_count") != null ? myNode.SelectSingleNode("followers_count").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundColor = myNode.SelectSingleNode("profile_background_color") != null ? myNode.SelectSingleNode("profile_background_color").InnerText : string.Empty;
                                dm.Recipient.ProfileTextColor = myNode.SelectSingleNode("profile_text_color") != null ? myNode.SelectSingleNode("profile_text_color").InnerText : string.Empty;
                                dm.Recipient.ProfileLinkColor = myNode.SelectSingleNode("profile_link_color") != null ? myNode.SelectSingleNode("profile_link_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarFillColor = myNode.SelectSingleNode("profile_sidebar_fill_color") != null ? myNode.SelectSingleNode("profile_sidebar_fill_color").InnerText : string.Empty;
                                dm.Recipient.ProfileSidebarBorderColor = myNode.SelectSingleNode("profile_sidebar_border_color") != null ? myNode.SelectSingleNode("profile_sidebar_border_color").InnerText : string.Empty;
                                dm.Recipient.FriendsCount = myNode.SelectSingleNode("friends_count") != null ? myNode.SelectSingleNode("friends_count").InnerText : string.Empty;
                                dm.Recipient.UtcOffset = myNode.SelectSingleNode("utc_offset") != null ? myNode.SelectSingleNode("utc_offset").InnerText : string.Empty;
                                dm.Recipient.TimeZone = myNode.SelectSingleNode("time_zone") != null ? myNode.SelectSingleNode("time_zone").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundImageUrl = myNode.SelectSingleNode("profile_background_image_url") != null ? myNode.SelectSingleNode("profile_background_image_url").InnerText : string.Empty;
                                dm.Recipient.ProfileBackgroundTile = myNode.SelectSingleNode("profile_background_tile") != null ? myNode.SelectSingleNode("profile_background_tile").InnerText : string.Empty;
                                dm.Recipient.StatusesCount = myNode.SelectSingleNode("statuses_count") != null ? myNode.SelectSingleNode("statuses_count").InnerText : string.Empty;
                                dm.Recipient.Notifications = myNode.SelectSingleNode("notifications") != null ? myNode.SelectSingleNode("notifications").InnerText : string.Empty;
                                dm.Recipient.Following = myNode.SelectSingleNode("following") != null ? myNode.SelectSingleNode("following").InnerText : string.Empty;
                                dm.Recipient.Verified = myNode.SelectSingleNode("verified") != null ? myNode.SelectSingleNode("verified").InnerText : string.Empty;


                                sfArray.Add(dm);
                            }
                            break;
                        }
                }
                return sfArray;
            }
            catch
            {
                return null;
            }
        }
        #endregion

        #region Direct Messages / New


        public static string Direct_Message_New(string username, string password, string to, string text)
        {
            try
            {
                HttpWebRequest messageRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/direct_messages/new.xml?user=" + to + "&text=" + text);
                messageRequest.Method = "POST";
                messageRequest.Credentials = new NetworkCredential(username, password);
                messageRequest.ContentLength = 0;
                messageRequest.ContentType = "application/x-www-form-urlencoded";
                WebResponse response = messageRequest.GetResponse();
                StreamReader sReader = new StreamReader(response.GetResponseStream());
                return sReader.ReadToEnd();
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
        #endregion

        #region Direct Messages / Destroy

        /// <summary>
        /// Destroys the direct message specified in the required ID parameter.  
        /// The authenticating user must be the recipient of the specified direct message.
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        /// <param name="messageID">Twitter Direct Message ID.</param>
        /// <returns></returns>
        public static string Direct_Message_Destroy(string username, string password, string messageID)
        {
            try
            {
                WebRequest request = HttpWebRequest.Create("http://twitter.com/direct_messages/destroy/" + messageID + ".xml");
                request.Method = "DELETE";
                request.ContentLength = 0;
                request.Credentials = new NetworkCredential(username, password);

                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                StreamReader responseStream = new StreamReader(response.GetResponseStream());

                string responseString = responseStream.ReadToEnd();

                return responseString;
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
        #endregion

        #region Friendships / Create

        public enum FriendshipID
        {
            ByID,
            ByUserID,
            ByScreenName,
            Follow
        }

        /// <summary>
        /// Allows the authenticating users to follow the user specified
        /// in the ID parameter.  Returns the befriended user in the requested
        /// format when successful.  Returns a string describing the failure 
        /// condition when unsuccessful. If you are already friends with the
        /// user an HTTP 403 will be returned.
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        /// <param name="friendshipID">The friendship creation type.</param>
        /// <param name="id">The friendship parameter value.</param>
        /// <returns></returns>
        public static string Friendship_Create(string username, string password, FriendshipID friendshipID, string id)
        {
            try
            {
                string responseStr = string.Empty;

                switch (friendshipID)
                {
                    case FriendshipID.ByID:
                        {
                            HttpWebRequest messageRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/friendships/create/" + id + ".xml");
                            messageRequest.Method = "POST";
                            messageRequest.Credentials = new NetworkCredential(username, password);
                            messageRequest.ContentLength = 0;
                            messageRequest.ContentType = "application/x-www-form-urlencoded";
                            WebResponse response = messageRequest.GetResponse();
                            StreamReader sReader = new StreamReader(response.GetResponseStream());
                            responseStr = sReader.ReadToEnd();

                            break;
                        }
                    case FriendshipID.ByScreenName:
                        {
                            HttpWebRequest messageRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/friendships/create.xml?screen_name=" + id);
                            messageRequest.Method = "POST";
                            messageRequest.Credentials = new NetworkCredential(username, password);
                            messageRequest.ContentLength = 0;
                            messageRequest.ContentType = "application/x-www-form-urlencoded";
                            WebResponse response = messageRequest.GetResponse();
                            StreamReader sReader = new StreamReader(response.GetResponseStream());
                            responseStr = sReader.ReadToEnd();

                            break;
                        }
                    case FriendshipID.ByUserID:
                        {
                            HttpWebRequest messageRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/friendships/create.xml?user_id=" + id);
                            messageRequest.Method = "POST";
                            messageRequest.Credentials = new NetworkCredential(username, password);
                            messageRequest.ContentLength = 0;
                            messageRequest.ContentType = "application/x-www-form-urlencoded";
                            WebResponse response = messageRequest.GetResponse();
                            StreamReader sReader = new StreamReader(response.GetResponseStream());
                            responseStr = sReader.ReadToEnd();

                            break;
                        }
                    case FriendshipID.Follow:
                        {
                            HttpWebRequest messageRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/friendships/create/" + id + ".xml?follow=true");
                            messageRequest.Method = "POST";
                            messageRequest.Credentials = new NetworkCredential(username, password);
                            messageRequest.ContentLength = 0;
                            messageRequest.ContentType = "application/x-www-form-urlencoded";
                            WebResponse response = messageRequest.GetResponse();
                            StreamReader sReader = new StreamReader(response.GetResponseStream());
                            responseStr = sReader.ReadToEnd();

                            break;
                        }
                }
                return responseStr;
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }

        #endregion

        #region Friendships / Destroy

        public enum DestroyFriendship
        {
            ByID,
            ByUserID,
            ByScreenName
        }

        /// <summary>
        /// Allows the authenticating users to unfollow the user specified in the 
        /// ID parameter.  Returns the unfollowed user in the requested format 
        /// when successful.  Returns a string describing the failure condition 
        /// when unsuccessful.
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        /// <param name="destFriendship">Parameter by which to find the friendship to destroy.</param>
        /// <param name="id">Parameter that specifies the unique user ID.</param>
        public static string Friendship_Destroy(string username, string password, DestroyFriendship destFriendship, string id)
        {
            try
            {
                string responseString = string.Empty;

                switch (destFriendship)
                {
                    case DestroyFriendship.ByID:
                        {
                            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://twitter.com/friendships/destroy/" + id + ".xml");
                            request.Method = "DELETE";
                            request.ContentLength = 0;
                            request.Credentials = new NetworkCredential(username, password);

                            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                            StreamReader responseStream = new StreamReader(response.GetResponseStream());

                            responseString = responseStream.ReadToEnd();

                            break;
                        }
                    case DestroyFriendship.ByScreenName:
                        {
                            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://twitter.com/friendships/destroy.xml?screen_name=" + id);
                            request.Method = "DELETE";
                            request.ContentLength = 0;
                            request.Credentials = new NetworkCredential(username, password);

                            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                            StreamReader responseStream = new StreamReader(response.GetResponseStream());

                            responseString = responseStream.ReadToEnd();

                            break;
                        }
                    case DestroyFriendship.ByUserID:
                        {
                            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://twitter.com/friendships/destroy.xml?user_id=" + id);
                            request.Method = "DELETE";
                            request.ContentLength = 0;
                            request.Credentials = new NetworkCredential(username, password);

                            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                            StreamReader responseStream = new StreamReader(response.GetResponseStream());

                            responseString = responseStream.ReadToEnd();

                            break;
                        }
                }

                return responseString;
            }
            catch
            {
                return null;
            }
        }

        #endregion

        #region Friendships / Exists

        /// <summary>
        /// 
        /// </summary>
        /// <param name="userA">The main user.</param>
        /// <param name="userB">The user to check for friendship.</param>

        public static string Friendship_Exists(string userA, string userB)
        {
            try
            {
                XmlReader feedReader = XmlReader.Create("http://twitter.com/friendships/exists.xml?user_a=" + userA + "&user_b=" + userB);
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(feedReader);

                string friends = xmlDocument.SelectSingleNode("/friends").InnerText;

                return friends;
            }
            catch
            {
                return null;
            }

        }

        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        /// <param name="userA">The main user.</param>
        /// <param name="userB">The user to check for friendship.</param>
        public static string Friendship_Exists(string username, string password, string userA, string userB)
        {
            try
            {
                XmlUrlResolver xmlResolver = new XmlUrlResolver();
                xmlResolver.Credentials = new NetworkCredential(username, password);

                XmlReaderSettings xmlSettings = new XmlReaderSettings();
                xmlSettings.XmlResolver = xmlResolver;

                XmlReader feedReader = XmlReader.Create("http://twitter.com/friendships/exists.xml?user_a=" + userA + "&user_b=" + userB, xmlSettings);
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(feedReader);

                string friends = xmlDocument.SelectSingleNode("/friends").InnerText;
                return friends;
            }
            catch
            {
                return null;
            }
        }

        #endregion

        #region Friendships / Show

        public enum SourceType
        {
            ByID,
            ByScreenName
        }

        public enum TargetType
        {
            ByID,
            ByScreenName
        }

        /// <summary>
        /// Returns detailed information about the relationship between two users.
        /// </summary>
        /// <param name="source">The type of the source user ID.</param>
        /// <param name="sourceValue">The source user ID.</param>
        /// <param name="target">The type of the target user ID.</param>
        /// <param name="targetValue">The type of the target user ID.</param>
        public static Relationship Friendship_Show(SourceType source, string sourceValue, TargetType target, string targetValue)
        {
            try
            {
                Relationship rel = new Relationship();

                switch (source)
                {
                    case SourceType.ByID:
                        {
                            switch (target)
                            {
                                case TargetType.ByID:
                                    {
                                        XmlReader feedReader = XmlReader.Create("http://twitter.com/friendships/show.xml?source_id=" + sourceValue + "&target_id=" + targetValue);
                                        XmlDocument xmlDocument = new XmlDocument();
                                        xmlDocument.Load(feedReader);

                                        rel.SourceFollowedBy = xmlDocument.SelectSingleNode("/relationship/source/followed_by") != null ? xmlDocument.SelectSingleNode("/relationship/source/followed_by").InnerText : string.Empty;
                                        rel.SourceFollowing = xmlDocument.SelectSingleNode("/relationship/source/following") != null ? xmlDocument.SelectSingleNode("/relationship/source/following").InnerText : string.Empty;
                                        rel.SourceID = xmlDocument.SelectSingleNode("/relationship/source/id") != null ? xmlDocument.SelectSingleNode("/relationship/source/id").InnerText : string.Empty;
                                        rel.SourceNotificationsEnabled = xmlDocument.SelectSingleNode("/relationship/source/notifications_enabled") != null ? xmlDocument.SelectSingleNode("/relationship/source/notifications_enabled").InnerText : string.Empty;
                                        rel.SourceScreenName = xmlDocument.SelectSingleNode("/relationship/source/screen_name") != null ? xmlDocument.SelectSingleNode("/relationship/source/screen_name").InnerText : string.Empty;

                                        rel.TargetFollowedBy = xmlDocument.SelectSingleNode("/relationship/target/followed_by") != null ? xmlDocument.SelectSingleNode("/relationship/target/followed_by").InnerText : string.Empty;
                                        rel.TargetFollowing = xmlDocument.SelectSingleNode("/relationship/target/following") != null ? xmlDocument.SelectSingleNode("/relationship/target/following").InnerText : string.Empty;
                                        rel.TargetID = xmlDocument.SelectSingleNode("/relationship/target/id") != null ? xmlDocument.SelectSingleNode("/relationship/target/id").InnerText : string.Empty;
                                        rel.TargetNotificationsEnabled = xmlDocument.SelectSingleNode("/relationship/target/notifications_enabled") != null ? xmlDocument.SelectSingleNode("/relationship/target/notifications_enabled").InnerText : string.Empty;
                                        rel.TargetScreenName = xmlDocument.SelectSingleNode("/relationship/target/screen_name") != null ? xmlDocument.SelectSingleNode("/relationship/target/screen_name").InnerText : string.Empty;

                                        break;
                                    }
                                case TargetType.ByScreenName:
                                    {
                                        XmlReader feedReader = XmlReader.Create("http://twitter.com/friendships/show.xml?source_id=" + sourceValue + "&target_screen_name=" + targetValue);
                                        XmlDocument xmlDocument = new XmlDocument();
                                        xmlDocument.Load(feedReader);

                                        rel.SourceFollowedBy = xmlDocument.SelectSingleNode("/relationship/source/followed_by") != null ? xmlDocument.SelectSingleNode("/relationship/source/followed_by").InnerText : string.Empty;
                                        rel.SourceFollowing = xmlDocument.SelectSingleNode("/relationship/source/following") != null ? xmlDocument.SelectSingleNode("/relationship/source/following").InnerText : string.Empty;
                                        rel.SourceID = xmlDocument.SelectSingleNode("/relationship/source/id") != null ? xmlDocument.SelectSingleNode("/relationship/source/id").InnerText : string.Empty;
                                        rel.SourceNotificationsEnabled = xmlDocument.SelectSingleNode("/relationship/source/notifications_enabled") != null ? xmlDocument.SelectSingleNode("/relationship/source/notifications_enabled").InnerText : string.Empty;
                                        rel.SourceScreenName = xmlDocument.SelectSingleNode("/relationship/source/screen_name") != null ? xmlDocument.SelectSingleNode("/relationship/source/screen_name").InnerText : string.Empty;

                                        rel.TargetFollowedBy = xmlDocument.SelectSingleNode("/relationship/target/followed_by") != null ? xmlDocument.SelectSingleNode("/relationship/target/followed_by").InnerText : string.Empty;
                                        rel.TargetFollowing = xmlDocument.SelectSingleNode("/relationship/target/following") != null ? xmlDocument.SelectSingleNode("/relationship/target/following").InnerText : string.Empty;
                                        rel.TargetID = xmlDocument.SelectSingleNode("/relationship/target/id") != null ? xmlDocument.SelectSingleNode("/relationship/target/id").InnerText : string.Empty;
                                        rel.TargetNotificationsEnabled = xmlDocument.SelectSingleNode("/relationship/target/notifications_enabled") != null ? xmlDocument.SelectSingleNode("/relationship/target/notifications_enabled").InnerText : string.Empty;
                                        rel.TargetScreenName = xmlDocument.SelectSingleNode("/relationship/target/screen_name") != null ? xmlDocument.SelectSingleNode("/relationship/target/screen_name").InnerText : string.Empty;

                                        break;
                                    }
                            }
                            break;
                        }
                    case SourceType.ByScreenName:
                        {
                            switch (target)
                            {
                                case TargetType.ByID:
                                    {
                                        XmlReader feedReader = XmlReader.Create("http://twitter.com/friendships/show.xml?source_screen_name=" + sourceValue + "&target_id=" + targetValue);
                                        XmlDocument xmlDocument = new XmlDocument();
                                        xmlDocument.Load(feedReader);

                                        rel.SourceFollowedBy = xmlDocument.SelectSingleNode("/relationship/source/followed_by") != null ? xmlDocument.SelectSingleNode("/relationship/source/followed_by").InnerText : string.Empty;
                                        rel.SourceFollowing = xmlDocument.SelectSingleNode("/relationship/source/following") != null ? xmlDocument.SelectSingleNode("/relationship/source/following").InnerText : string.Empty;
                                        rel.SourceID = xmlDocument.SelectSingleNode("/relationship/source/id") != null ? xmlDocument.SelectSingleNode("/relationship/source/id").InnerText : string.Empty;
                                        rel.SourceNotificationsEnabled = xmlDocument.SelectSingleNode("/relationship/source/notifications_enabled") != null ? xmlDocument.SelectSingleNode("/relationship/source/notifications_enabled").InnerText : string.Empty;
                                        rel.SourceScreenName = xmlDocument.SelectSingleNode("/relationship/source/screen_name") != null ? xmlDocument.SelectSingleNode("/relationship/source/screen_name").InnerText : string.Empty;

                                        rel.TargetFollowedBy = xmlDocument.SelectSingleNode("/relationship/target/followed_by") != null ? xmlDocument.SelectSingleNode("/relationship/target/followed_by").InnerText : string.Empty;
                                        rel.TargetFollowing = xmlDocument.SelectSingleNode("/relationship/target/following") != null ? xmlDocument.SelectSingleNode("/relationship/target/following").InnerText : string.Empty;
                                        rel.TargetID = xmlDocument.SelectSingleNode("/relationship/target/id") != null ? xmlDocument.SelectSingleNode("/relationship/target/id").InnerText : string.Empty;
                                        rel.TargetNotificationsEnabled = xmlDocument.SelectSingleNode("/relationship/target/notifications_enabled") != null ? xmlDocument.SelectSingleNode("/relationship/target/notifications_enabled").InnerText : string.Empty;
                                        rel.TargetScreenName = xmlDocument.SelectSingleNode("/relationship/target/screen_name") != null ? xmlDocument.SelectSingleNode("/relationship/target/screen_name").InnerText : string.Empty;

                                        break;
                                    }
                                case TargetType.ByScreenName:
                                    {
                                        XmlReader feedReader = XmlReader.Create("http://twitter.com/friendships/show.xml?source_screen_name=" + sourceValue + "&target_screen_name=" + targetValue);
                                        XmlDocument xmlDocument = new XmlDocument();
                                        xmlDocument.Load(feedReader);

                                        rel.SourceFollowedBy = xmlDocument.SelectSingleNode("/relationship/source/followed_by") != null ? xmlDocument.SelectSingleNode("/relationship/source/followed_by").InnerText : string.Empty;
                                        rel.SourceFollowing = xmlDocument.SelectSingleNode("/relationship/source/following") != null ? xmlDocument.SelectSingleNode("/relationship/source/following").InnerText : string.Empty;
                                        rel.SourceID = xmlDocument.SelectSingleNode("/relationship/source/id") != null ? xmlDocument.SelectSingleNode("/relationship/source/id").InnerText : string.Empty;
                                        rel.SourceNotificationsEnabled = xmlDocument.SelectSingleNode("/relationship/source/notifications_enabled") != null ? xmlDocument.SelectSingleNode("/relationship/source/notifications_enabled").InnerText : string.Empty;
                                        rel.SourceScreenName = xmlDocument.SelectSingleNode("/relationship/source/screen_name") != null ? xmlDocument.SelectSingleNode("/relationship/source/screen_name").InnerText : string.Empty;

                                        rel.TargetFollowedBy = xmlDocument.SelectSingleNode("/relationship/target/followed_by") != null ? xmlDocument.SelectSingleNode("/relationship/target/followed_by").InnerText : string.Empty;
                                        rel.TargetFollowing = xmlDocument.SelectSingleNode("/relationship/target/following") != null ? xmlDocument.SelectSingleNode("/relationship/target/following").InnerText : string.Empty;
                                        rel.TargetID = xmlDocument.SelectSingleNode("/relationship/target/id") != null ? xmlDocument.SelectSingleNode("/relationship/target/id").InnerText : string.Empty;
                                        rel.TargetNotificationsEnabled = xmlDocument.SelectSingleNode("/relationship/target/notifications_enabled") != null ? xmlDocument.SelectSingleNode("/relationship/target/notifications_enabled").InnerText : string.Empty;
                                        rel.TargetScreenName = xmlDocument.SelectSingleNode("/relationship/target/screen_name") != null ? xmlDocument.SelectSingleNode("/relationship/target/screen_name").InnerText : string.Empty;

                                        break;
                                    }
                            }
                            break;
                        }
                }
                return rel;
            }
            catch
            {
                return null;
            }
        }

        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        /// <param name="target">The type of the target user ID.</param>
        /// <param name="targetValue">The type of the target user ID.</param>
        public static Relationship Friendship_Show(string username, string password, TargetType target, string targetValue)
        {
            try
            {
                Relationship rel = new Relationship();

                XmlUrlResolver xmlResolver = new XmlUrlResolver();
                xmlResolver.Credentials = new NetworkCredential(username, password);

                XmlReaderSettings xmlSettings = new XmlReaderSettings();
                xmlSettings.XmlResolver = xmlResolver;

                switch (target)
                {
                    case TargetType.ByID:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/friendships/show.xml?source_screen_name=" + username + "&target_id=" + targetValue, xmlSettings);
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            rel.SourceFollowedBy = xmlDocument.SelectSingleNode("/relationship/source/followed_by") != null ? xmlDocument.SelectSingleNode("/relationship/source/followed_by").InnerText : string.Empty;
                            rel.SourceFollowing = xmlDocument.SelectSingleNode("/relationship/source/following") != null ? xmlDocument.SelectSingleNode("/relationship/source/following").InnerText : string.Empty;
                            rel.SourceID = xmlDocument.SelectSingleNode("/relationship/source/id") != null ? xmlDocument.SelectSingleNode("/relationship/source/id").InnerText : string.Empty;
                            rel.SourceNotificationsEnabled = xmlDocument.SelectSingleNode("/relationship/source/notifications_enabled") != null ? xmlDocument.SelectSingleNode("/relationship/source/notifications_enabled").InnerText : string.Empty;
                            rel.SourceScreenName = xmlDocument.SelectSingleNode("/relationship/source/screen_name") != null ? xmlDocument.SelectSingleNode("/relationship/source/screen_name").InnerText : string.Empty;

                            rel.TargetFollowedBy = xmlDocument.SelectSingleNode("/relationship/target/followed_by") != null ? xmlDocument.SelectSingleNode("/relationship/target/followed_by").InnerText : string.Empty;
                            rel.TargetFollowing = xmlDocument.SelectSingleNode("/relationship/target/following") != null ? xmlDocument.SelectSingleNode("/relationship/target/following").InnerText : string.Empty;
                            rel.TargetID = xmlDocument.SelectSingleNode("/relationship/target/id") != null ? xmlDocument.SelectSingleNode("/relationship/target/id").InnerText : string.Empty;
                            rel.TargetNotificationsEnabled = xmlDocument.SelectSingleNode("/relationship/target/notifications_enabled") != null ? xmlDocument.SelectSingleNode("/relationship/target/notifications_enabled").InnerText : string.Empty;
                            rel.TargetScreenName = xmlDocument.SelectSingleNode("/relationship/target/screen_name") != null ? xmlDocument.SelectSingleNode("/relationship/target/screen_name").InnerText : string.Empty;

                            break;
                        }
                    case TargetType.ByScreenName:
                        {
                            XmlReader feedReader = XmlReader.Create("http://twitter.com/friendships/show.xml?source_screen_name=" + username + "&target_screen_name=" + targetValue, xmlSettings);
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load(feedReader);

                            rel.SourceFollowedBy = xmlDocument.SelectSingleNode("/relationship/source/followed_by") != null ? xmlDocument.SelectSingleNode("/relationship/source/followed_by").InnerText : string.Empty;
                            rel.SourceFollowing = xmlDocument.SelectSingleNode("/relationship/source/following") != null ? xmlDocument.SelectSingleNode("/relationship/source/following").InnerText : string.Empty;
                            rel.SourceID = xmlDocument.SelectSingleNode("/relationship/source/id") != null ? xmlDocument.SelectSingleNode("/relationship/source/id").InnerText : string.Empty;
                            rel.SourceNotificationsEnabled = xmlDocument.SelectSingleNode("/relationship/source/notifications_enabled") != null ? xmlDocument.SelectSingleNode("/relationship/source/notifications_enabled").InnerText : string.Empty;
                            rel.SourceScreenName = xmlDocument.SelectSingleNode("/relationship/source/screen_name") != null ? xmlDocument.SelectSingleNode("/relationship/source/screen_name").InnerText : string.Empty;

                            rel.TargetFollowedBy = xmlDocument.SelectSingleNode("/relationship/target/followed_by") != null ? xmlDocument.SelectSingleNode("/relationship/target/followed_by").InnerText : string.Empty;
                            rel.TargetFollowing = xmlDocument.SelectSingleNode("/relationship/target/following") != null ? xmlDocument.SelectSingleNode("/relationship/target/following").InnerText : string.Empty;
                            rel.TargetID = xmlDocument.SelectSingleNode("/relationship/target/id") != null ? xmlDocument.SelectSingleNode("/relationship/target/id").InnerText : string.Empty;
                            rel.TargetNotificationsEnabled = xmlDocument.SelectSingleNode("/relationship/target/notifications_enabled") != null ? xmlDocument.SelectSingleNode("/relationship/target/notifications_enabled").InnerText : string.Empty;
                            rel.TargetScreenName = xmlDocument.SelectSingleNode("/relationship/target/screen_name") != null ? xmlDocument.SelectSingleNode("/relationship/target/screen_name").InnerText : string.Empty;

                            break;
                        }
                }
                return rel;
            }
            catch
            {
                return null;
            }
        }
        #endregion

        #region Friends / IDs

        public enum Friends
        {
            ByID,
            ByUserID,
            ByScreenName
        }

        public enum Page
        {
            Use,
            DoNotUse
        }

        /// <summary>
        /// Returns an array of numeric IDs for every user the specified user is following.
        /// </summary>
        /// <param name="friends">The type of search by which to identify a user.</param>
        /// <param name="fParam">Twitter user identification parameter.</param>
        /// <param name="page">Parameter that shows whether to use pages or not.</param>
        /// <param name="pageNum">Page number.</param>

        public static ArrayList Friends_Ids(Friends friends, string fParam, Page page, string pageNum)
        {
            try
            {
                ArrayList aList = new ArrayList();

                switch (friends)
                {
                    case Friends.ByID:
                        {
                            switch (page)
                            {
                                case Page.DoNotUse:
                                    {

                                        XmlReader xmlReader = XmlReader.Create("http://twitter.com/friends/ids/" + fParam + ".xml");
                                        XmlDocument xmlDoc = new XmlDocument();
                                        xmlDoc.Load(xmlReader);

                                        foreach (XmlNode node in xmlDoc.SelectNodes("/ids/id"))
                                        {
                                            aList.Add(node.InnerText);
                                        }

                                        break;
                                    }
                                case Page.Use:
                                    {
                                        XmlReader xmlReader = XmlReader.Create("http://twitter.com/friends/ids/" + fParam + ".xml&page=" + pageNum);
                                        XmlDocument xmlDoc = new XmlDocument();
                                        xmlDoc.Load(xmlReader);

                                        foreach (XmlNode node in xmlDoc.SelectNodes("/ids/id"))
                                        {
                                            aList.Add(node.InnerText);
                                        }

                                        break;
                                    }
                            }

                            break;
                        }

                    case Friends.ByScreenName:
                        {
                            switch (page)
                            {
                                case Page.DoNotUse:
                                    {
                                        XmlReader xmlReader = XmlReader.Create("http://twitter.com/friends/ids.xml?screen_name=" + fParam);
                                        XmlDocument xmlDoc = new XmlDocument();
                                        xmlDoc.Load(xmlReader);

                                        foreach (XmlNode node in xmlDoc.SelectNodes("/ids/id"))
                                        {
                                            aList.Add(node.InnerText);
                                        }

                                        break;
                                    }
                                case Page.Use:
                                    {
                                        XmlReader xmlReader = XmlReader.Create("http://twitter.com/friends/ids.xml?screen_name=" + fParam + "&page=" + pageNum);
                                        XmlDocument xmlDoc = new XmlDocument();
                                        xmlDoc.Load(xmlReader);

                                        foreach (XmlNode node in xmlDoc.SelectNodes("/ids/id"))
                                        {
                                            aList.Add(node.InnerText);
                                        }

                                        break;
                                    }
                            }

                            break;
                        }

                    case Friends.ByUserID:
                        {
                            switch (page)
                            {
                                case Page.DoNotUse:
                                    {
                                        XmlReader xmlReader = XmlReader.Create("http://twitter.com/friends/ids.xml?user_id=" + fParam);
                                        XmlDocument xmlDoc = new XmlDocument();
                                        xmlDoc.Load(xmlReader);

                                        foreach (XmlNode node in xmlDoc.SelectNodes("/ids/id"))
                                        {
                                            aList.Add(node.InnerText);
                                        }

                                        break;
                                    }
                                case Page.Use:
                                    {
                                        XmlReader xmlReader = XmlReader.Create("http://twitter.com/friends/ids.xml?user_id=" + fParam + "&page=" + pageNum);
                                        XmlDocument xmlDoc = new XmlDocument();
                                        xmlDoc.Load(xmlReader);

                                        foreach (XmlNode node in xmlDoc.SelectNodes("/ids/id"))
                                        {
                                            aList.Add(node.InnerText);
                                        }

                                        break;
                                    }
                            }
                            break;
                        }
                }

                return aList;
            }
            catch
            {
                return null;
            }
        }

        #endregion

        #region Followers / IDs

        public enum Followers
        {
            ByID,
            ByUserID,
            ByScreenName
        }

        /// <summary>
        /// Returns an array of numeric IDs for every user following the specified user.
        /// </summary>
        /// <param name="followers">The type of search by which to identify a user.</param>
        /// <param name="fParam">Twitter user identification parameter.</param>
        /// <param name="page">Parameter that shows whether to use pages or not.</param>
        /// <param name="pageNum">Page number.</param>
        /// 
        public static ArrayList Followers_Ids(Followers followers, string fParam, Page page, string pageNum)
        {
            try
            {
                ArrayList aList = new ArrayList();

                switch (followers)
                {
                    case Followers.ByID:
                        {
                            switch (page)
                            {
                                case Page.DoNotUse:
                                    {

                                        XmlReader xmlReader = XmlReader.Create("http://twitter.com/followers/ids/" + fParam + ".xml");
                                        XmlDocument xmlDoc = new XmlDocument();
                                        xmlDoc.Load(xmlReader);

                                        foreach (XmlNode node in xmlDoc.SelectNodes("/ids/id"))
                                        {
                                            aList.Add(node.InnerText);
                                        }

                                        break;
                                    }
                                case Page.Use:
                                    {
                                        XmlReader xmlReader = XmlReader.Create("http://twitter.com/followers/ids/" + fParam + ".xml&page=" + pageNum);
                                        XmlDocument xmlDoc = new XmlDocument();
                                        xmlDoc.Load(xmlReader);

                                        foreach (XmlNode node in xmlDoc.SelectNodes("/ids/id"))
                                        {
                                            aList.Add(node.InnerText);
                                        }

                                        break;
                                    }
                            }

                            break;
                        }

                    case Followers.ByScreenName:
                        {
                            switch (page)
                            {
                                case Page.DoNotUse:
                                    {
                                        XmlReader xmlReader = XmlReader.Create("http://twitter.com/followers/ids.xml?screen_name=" + fParam);
                                        XmlDocument xmlDoc = new XmlDocument();
                                        xmlDoc.Load(xmlReader);

                                        foreach (XmlNode node in xmlDoc.SelectNodes("/ids/id"))
                                        {
                                            aList.Add(node.InnerText);
                                        }

                                        break;
                                    }
                                case Page.Use:
                                    {
                                        XmlReader xmlReader = XmlReader.Create("http://twitter.com/followers/ids.xml?screen_name=" + fParam + "&page=" + pageNum);
                                        XmlDocument xmlDoc = new XmlDocument();
                                        xmlDoc.Load(xmlReader);

                                        foreach (XmlNode node in xmlDoc.SelectNodes("/ids/id"))
                                        {
                                            aList.Add(node.InnerText);
                                        }

                                        break;
                                    }
                            }

                            break;
                        }

                    case Followers.ByUserID:
                        {
                            switch (page)
                            {
                                case Page.DoNotUse:
                                    {
                                        XmlReader xmlReader = XmlReader.Create("http://twitter.com/followers/ids.xml?user_id=" + fParam);
                                        XmlDocument xmlDoc = new XmlDocument();
                                        xmlDoc.Load(xmlReader);

                                        foreach (XmlNode node in xmlDoc.SelectNodes("/ids/id"))
                                        {
                                            aList.Add(node.InnerText);
                                        }

                                        break;
                                    }
                                case Page.Use:
                                    {
                                        XmlReader xmlReader = XmlReader.Create("http://twitter.com/followers/ids.xml?user_id=" + fParam + "&page=" + pageNum);
                                        XmlDocument xmlDoc = new XmlDocument();
                                        xmlDoc.Load(xmlReader);

                                        foreach (XmlNode node in xmlDoc.SelectNodes("/ids/id"))
                                        {
                                            aList.Add(node.InnerText);
                                        }

                                        break;
                                    }
                            }
                            break;
                        }
                }

                return aList;
            }
            catch
            {
                return null;
            }
        }


        #endregion

        #region Account / Verify Credentials

        public static User Account_Credentials(string username, string password)
        {
            try
            {
                XmlUrlResolver xmlResolver = new XmlUrlResolver();
                xmlResolver.Credentials = new NetworkCredential(username, password);

                XmlReaderSettings xmlSettings = new XmlReaderSettings();
                xmlSettings.XmlResolver = xmlResolver;

                XmlReader xmlReader = XmlReader.Create("http://twitter.com/account/verify_credentials.xml", xmlSettings);
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(xmlReader);

                User userQuery = new User();

                userQuery.ID = xmlDoc.SelectSingleNode("/user/id") != null ? xmlDoc.SelectSingleNode("/user/id").InnerText : string.Empty;
                userQuery.Name = xmlDoc.SelectSingleNode("/user/name") != null ? xmlDoc.SelectSingleNode("/user/name").InnerText : string.Empty;
                userQuery.ScreenName = xmlDoc.SelectSingleNode("/user/screen_name") != null ? xmlDoc.SelectSingleNode("/user/screen_name").InnerText : string.Empty;
                userQuery.Location = xmlDoc.SelectSingleNode("/user/location") != null ? xmlDoc.SelectSingleNode("/user/location").InnerText : string.Empty;
                userQuery.Description = xmlDoc.SelectSingleNode("/user/description") != null ? xmlDoc.SelectSingleNode("/user/description").InnerText : string.Empty;
                userQuery.ProfileImageURL = xmlDoc.SelectSingleNode("/user/profile_image_url") != null ? xmlDoc.SelectSingleNode("/user/profile_image_url").InnerText : string.Empty;
                userQuery.URL = xmlDoc.SelectSingleNode("/user/url") != null ? xmlDoc.SelectSingleNode("/user/url").InnerText : string.Empty;
                userQuery.Protected = xmlDoc.SelectSingleNode("/user/protected") != null ? xmlDoc.SelectSingleNode("/user/protected").InnerText : string.Empty;
                userQuery.Followers = xmlDoc.SelectSingleNode("/user/followers_count") != null ? xmlDoc.SelectSingleNode("/user/followers_count").InnerText : string.Empty;
                userQuery.ProfileBackgroundColor = xmlDoc.SelectSingleNode("/user/profile_background_color") != null ? xmlDoc.SelectSingleNode("/user/profile_background_color").InnerText : string.Empty;
                userQuery.ProfileTextColor = xmlDoc.SelectSingleNode("/user/profile_text_color") != null ? xmlDoc.SelectSingleNode("/user/profile_text_color").InnerText : string.Empty;
                userQuery.ProfileLinkColor = xmlDoc.SelectSingleNode("/user/profile_link_color") != null ? xmlDoc.SelectSingleNode("/user/profile_link_color").InnerText : string.Empty;
                userQuery.ProfileSidebarFillColor = xmlDoc.SelectSingleNode("/user/profile_sidebar_fill_color") != null ? xmlDoc.SelectSingleNode("/user/profile_sidebar_fill_color").InnerText : string.Empty;
                userQuery.ProfileSidebarBorderColor = xmlDoc.SelectSingleNode("/user/profile_sidebar_border_color") != null ? xmlDoc.SelectSingleNode("/user/profile_sidebar_border_color").InnerText : string.Empty;
                userQuery.FriendsCount = xmlDoc.SelectSingleNode("/user/friends_count") != null ? xmlDoc.SelectSingleNode("/user/friends_count").InnerText : string.Empty;
                userQuery.UtcOffset = xmlDoc.SelectSingleNode("/user/utc_offset") != null ? xmlDoc.SelectSingleNode("/user/utc_offset").InnerText : string.Empty;
                userQuery.TimeZone = xmlDoc.SelectSingleNode("/user/time_zone") != null ? xmlDoc.SelectSingleNode("/user/time_zone").InnerText : string.Empty;
                userQuery.ProfileBackgroundImageUrl = xmlDoc.SelectSingleNode("/user/profile_background_image_url") != null ? xmlDoc.SelectSingleNode("/user/profile_background_image_url").InnerText : string.Empty;
                userQuery.ProfileBackgroundTile = xmlDoc.SelectSingleNode("/user/profile_background_tile") != null ? xmlDoc.SelectSingleNode("/user/profile_background_tile").InnerText : string.Empty;
                userQuery.StatusesCount = xmlDoc.SelectSingleNode("/user/statuses_count") != null ? xmlDoc.SelectSingleNode("/user/statuses_count").InnerText : string.Empty;
                userQuery.Notifications = xmlDoc.SelectSingleNode("/user/notifications") != null ? xmlDoc.SelectSingleNode("/user/notifications").InnerText : string.Empty;
                userQuery.Following = xmlDoc.SelectSingleNode("/user/following") != null ? xmlDoc.SelectSingleNode("/user/following").InnerText : string.Empty;
                userQuery.Verified = xmlDoc.SelectSingleNode("/user/verified") != null ? xmlDoc.SelectSingleNode("/user/verified").InnerText : string.Empty;
                userQuery.StatusCreatedAt = xmlDoc.SelectSingleNode("/user/status/created_at") != null ? xmlDoc.SelectSingleNode("/user/status/created_at").InnerText : string.Empty;
                userQuery.StatusID = xmlDoc.SelectSingleNode("/user/status/id") != null ? xmlDoc.SelectSingleNode("/user/status/id").InnerText : string.Empty;
                userQuery.StatusText = xmlDoc.SelectSingleNode("/user/status/text") != null ? xmlDoc.SelectSingleNode("/user/status/text").InnerText : string.Empty;
                userQuery.StatusSource = xmlDoc.SelectSingleNode("/user/status/source") != null ? xmlDoc.SelectSingleNode("/user/status/source").InnerText : string.Empty;
                userQuery.StatusTruncated = xmlDoc.SelectSingleNode("/user/status/truncated") != null ? xmlDoc.SelectSingleNode("/user/status/truncated").InnerText : string.Empty;
                userQuery.StatusInReplyToStatusID = xmlDoc.SelectSingleNode("/user/status/in_reply_to_status_id") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_status_id").InnerText : string.Empty;
                userQuery.StatusInReplyToUserID = xmlDoc.SelectSingleNode("/user/status/in_reply_to_user_id") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_user_id").InnerText : string.Empty;
                userQuery.StatusFavorited = xmlDoc.SelectSingleNode("/user/status/favorited") != null ? xmlDoc.SelectSingleNode("/user/status/favorited").InnerText : string.Empty;
                userQuery.StatusInReplyToScreenName = xmlDoc.SelectSingleNode("/user/status/in_reply_to_screen_name") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_screen_name").InnerText : string.Empty;

                return userQuery;
            }
            catch
            {
                return null;
            }
        }

        #endregion

        #region Account / Rate Limit Status

        /// <summary>
        /// Returns the remaining number of API requests available to the 
        /// requesting user before the API limit is reached for the current 
        /// hour. Calls to rate_limit_status do not count against the rate limit. 
        /// If authentication credentials are provided, the rate limit status for
        /// the authenticating user is returned.  Otherwise, the rate limit status
        /// for the requester's IP address is returned. Learn more about the REST
        /// API rate limiting.
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        public static RateLimit Rate_Limit(string username, string password)
        {
            try
            {
                XmlUrlResolver xmlUR = new XmlUrlResolver();
                xmlUR.Credentials = new NetworkCredential(username, password);

                XmlReaderSettings xmlRS = new XmlReaderSettings();
                xmlRS.XmlResolver = xmlUR;

                XmlReader xmlReader = XmlReader.Create("http://twitter.com/account/rate_limit_status.xml", xmlRS);
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(xmlReader);

                RateLimit rateLimit = new RateLimit();

                rateLimit.RemainingHits = xmlDoc.SelectSingleNode("/hash/remaining-hits") != null ? xmlDoc.SelectSingleNode("/hash/remaining-hits").InnerText : string.Empty;
                rateLimit.HourlyLimit = xmlDoc.SelectSingleNode("/hash/hourly-limit") != null ? xmlDoc.SelectSingleNode("/hash/hourly-limit").InnerText : string.Empty;
                rateLimit.ResetTime = xmlDoc.SelectSingleNode("/hash/reset-time") != null ? xmlDoc.SelectSingleNode("/hash/reset-time").InnerText : string.Empty;
                rateLimit.RemainingHits = xmlDoc.SelectSingleNode("/hash/reset-time-in-seconds") != null ? xmlDoc.SelectSingleNode("/hash/reset-time-in-seconds").InnerText : string.Empty;

                return rateLimit;
            }
            catch
            {
                return null;
            }
        }

        public static RateLimit Rate_Limit()
        {
            try
            {
                XmlReader xmlReader = XmlReader.Create("http://twitter.com/account/rate_limit_status.xml");
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(xmlReader);

                RateLimit rateLimit = new RateLimit();

                rateLimit.RemainingHits = xmlDoc.SelectSingleNode("/hash/remaining-hits") != null ? xmlDoc.SelectSingleNode("/hash/remaining-hits").InnerText : string.Empty;
                rateLimit.HourlyLimit = xmlDoc.SelectSingleNode("/hash/hourly-limit") != null ? xmlDoc.SelectSingleNode("/hash/hourly-limit").InnerText : string.Empty;
                rateLimit.ResetTime = xmlDoc.SelectSingleNode("/hash/reset-time") != null ? xmlDoc.SelectSingleNode("/hash/reset-time").InnerText : string.Empty;
                rateLimit.RemainingHits = xmlDoc.SelectSingleNode("/hash/reset-time-in-seconds") != null ? xmlDoc.SelectSingleNode("/hash/reset-time-in-seconds").InnerText : string.Empty;

                return rateLimit;
            }
            catch
            {
                return null;
            }
        }

        #endregion

        #region Account / End Session

        /// <summary>
        /// Ends the session of the authenticating user, returning a null cookie.
        /// Use this method to sign users out of client-facing applications like widgets.
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        public static string Account_EndSession(string username, string password)
        {
            try
            {
                string responseStr;

                HttpWebRequest messageRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/account/end_session.xml");
                messageRequest.Method = "POST";
                messageRequest.Credentials = new NetworkCredential(username, password);
                messageRequest.ContentLength = 0;
                messageRequest.ContentType = "application/x-www-form-urlencoded";
                WebResponse response = messageRequest.GetResponse();
                StreamReader sReader = new StreamReader(response.GetResponseStream());
                responseStr = sReader.ReadToEnd();

                return responseStr;
            }
            catch
            {
                return string.Empty;
            }
        }

        #endregion

        #region Account / Update Delivery Device

        public enum DeliveryDevice
        {
            SMS,
            IM,
            None
        }

        /// <summary>
        /// Sets which device Twitter delivers updates to for the authenticating user.
        /// Sending none as the device parameter will disable IM or SMS updates.
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter acocunt password.</param>
        /// <param name="device">Delivery device.</param>
        public static User Account_UpdateDeliveryDevice(string username, string password, DeliveryDevice device)
        {
            try
            {
                User userQuery = new User();
                string responseStr;
                switch (device)
                {
                    case DeliveryDevice.IM:
                        {
                            HttpWebRequest messageRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/account/update_delivery_device.xml?device=im");
                            messageRequest.Method = "POST";
                            messageRequest.Credentials = new NetworkCredential(username, password);
                            messageRequest.ContentLength = 0;
                            messageRequest.ContentType = "application/x-www-form-urlencoded";
                            WebResponse response = messageRequest.GetResponse();
                            StreamReader sReader = new StreamReader(response.GetResponseStream());
                            responseStr = sReader.ReadToEnd();

                            XmlDocument xmlDoc = new XmlDocument();
                            xmlDoc.LoadXml(responseStr);

                            userQuery.ID = xmlDoc.SelectSingleNode("/user/id") != null ? xmlDoc.SelectSingleNode("/user/id").InnerText : string.Empty;
                            userQuery.Name = xmlDoc.SelectSingleNode("/user/name") != null ? xmlDoc.SelectSingleNode("/user/name").InnerText : string.Empty;
                            userQuery.ScreenName = xmlDoc.SelectSingleNode("/user/screen_name") != null ? xmlDoc.SelectSingleNode("/user/screen_name").InnerText : string.Empty;
                            userQuery.Location = xmlDoc.SelectSingleNode("/user/location") != null ? xmlDoc.SelectSingleNode("/user/location").InnerText : string.Empty;
                            userQuery.Description = xmlDoc.SelectSingleNode("/user/description") != null ? xmlDoc.SelectSingleNode("/user/description").InnerText : string.Empty;
                            userQuery.ProfileImageURL = xmlDoc.SelectSingleNode("/user/profile_image_url") != null ? xmlDoc.SelectSingleNode("/user/profile_image_url").InnerText : string.Empty;
                            userQuery.URL = xmlDoc.SelectSingleNode("/user/url") != null ? xmlDoc.SelectSingleNode("/user/url").InnerText : string.Empty;
                            userQuery.Protected = xmlDoc.SelectSingleNode("/user/protected") != null ? xmlDoc.SelectSingleNode("/user/protected").InnerText : string.Empty;
                            userQuery.Followers = xmlDoc.SelectSingleNode("/user/followers_count") != null ? xmlDoc.SelectSingleNode("/user/followers_count").InnerText : string.Empty;
                            userQuery.ProfileBackgroundColor = xmlDoc.SelectSingleNode("/user/profile_background_color") != null ? xmlDoc.SelectSingleNode("/user/profile_background_color").InnerText : string.Empty;
                            userQuery.ProfileTextColor = xmlDoc.SelectSingleNode("/user/profile_text_color") != null ? xmlDoc.SelectSingleNode("/user/profile_text_color").InnerText : string.Empty;
                            userQuery.ProfileLinkColor = xmlDoc.SelectSingleNode("/user/profile_link_color") != null ? xmlDoc.SelectSingleNode("/user/profile_link_color").InnerText : string.Empty;
                            userQuery.ProfileSidebarFillColor = xmlDoc.SelectSingleNode("/user/profile_sidebar_fill_color") != null ? xmlDoc.SelectSingleNode("/user/profile_sidebar_fill_color").InnerText : string.Empty;
                            userQuery.ProfileSidebarBorderColor = xmlDoc.SelectSingleNode("/user/profile_sidebar_border_color") != null ? xmlDoc.SelectSingleNode("/user/profile_sidebar_border_color").InnerText : string.Empty;
                            userQuery.FriendsCount = xmlDoc.SelectSingleNode("/user/friends_count") != null ? xmlDoc.SelectSingleNode("/user/friends_count").InnerText : string.Empty;
                            userQuery.UtcOffset = xmlDoc.SelectSingleNode("/user/utc_offset") != null ? xmlDoc.SelectSingleNode("/user/utc_offset").InnerText : string.Empty;
                            userQuery.TimeZone = xmlDoc.SelectSingleNode("/user/time_zone") != null ? xmlDoc.SelectSingleNode("/user/time_zone").InnerText : string.Empty;
                            userQuery.ProfileBackgroundImageUrl = xmlDoc.SelectSingleNode("/user/profile_background_image_url") != null ? xmlDoc.SelectSingleNode("/user/profile_background_image_url").InnerText : string.Empty;
                            userQuery.ProfileBackgroundTile = xmlDoc.SelectSingleNode("/user/profile_background_tile") != null ? xmlDoc.SelectSingleNode("/user/profile_background_tile").InnerText : string.Empty;
                            userQuery.StatusesCount = xmlDoc.SelectSingleNode("/user/statuses_count") != null ? xmlDoc.SelectSingleNode("/user/statuses_count").InnerText : string.Empty;
                            userQuery.Notifications = xmlDoc.SelectSingleNode("/user/notifications") != null ? xmlDoc.SelectSingleNode("/user/notifications").InnerText : string.Empty;
                            userQuery.Following = xmlDoc.SelectSingleNode("/user/following") != null ? xmlDoc.SelectSingleNode("/user/following").InnerText : string.Empty;
                            userQuery.Verified = xmlDoc.SelectSingleNode("/user/verified") != null ? xmlDoc.SelectSingleNode("/user/verified").InnerText : string.Empty;
                            userQuery.StatusCreatedAt = xmlDoc.SelectSingleNode("/user/status/created_at") != null ? xmlDoc.SelectSingleNode("/user/status/created_at").InnerText : string.Empty;
                            userQuery.StatusID = xmlDoc.SelectSingleNode("/user/status/id") != null ? xmlDoc.SelectSingleNode("/user/status/id").InnerText : string.Empty;
                            userQuery.StatusText = xmlDoc.SelectSingleNode("/user/status/text") != null ? xmlDoc.SelectSingleNode("/user/status/text").InnerText : string.Empty;
                            userQuery.StatusSource = xmlDoc.SelectSingleNode("/user/status/source") != null ? xmlDoc.SelectSingleNode("/user/status/source").InnerText : string.Empty;
                            userQuery.StatusTruncated = xmlDoc.SelectSingleNode("/user/status/truncated") != null ? xmlDoc.SelectSingleNode("/user/status/truncated").InnerText : string.Empty;
                            userQuery.StatusInReplyToStatusID = xmlDoc.SelectSingleNode("/user/status/in_reply_to_status_id") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_status_id").InnerText : string.Empty;
                            userQuery.StatusInReplyToUserID = xmlDoc.SelectSingleNode("/user/status/in_reply_to_user_id") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_user_id").InnerText : string.Empty;
                            userQuery.StatusFavorited = xmlDoc.SelectSingleNode("/user/status/favorited") != null ? xmlDoc.SelectSingleNode("/user/status/favorited").InnerText : string.Empty;
                            userQuery.StatusInReplyToScreenName = xmlDoc.SelectSingleNode("/user/status/in_reply_to_screen_name") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_screen_name").InnerText : string.Empty;

                            break;
                        }
                    case DeliveryDevice.SMS:
                        {
                            HttpWebRequest messageRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/account/update_delivery_device.xml?device=sms");
                            messageRequest.Method = "POST";
                            messageRequest.Credentials = new NetworkCredential(username, password);
                            messageRequest.ContentLength = 0;
                            messageRequest.ContentType = "application/x-www-form-urlencoded";
                            WebResponse response = messageRequest.GetResponse();
                            StreamReader sReader = new StreamReader(response.GetResponseStream());
                            responseStr = sReader.ReadToEnd();

                            XmlDocument xmlDoc = new XmlDocument();
                            xmlDoc.LoadXml(responseStr);

                            userQuery.ID = xmlDoc.SelectSingleNode("/user/id") != null ? xmlDoc.SelectSingleNode("/user/id").InnerText : string.Empty;
                            userQuery.Name = xmlDoc.SelectSingleNode("/user/name") != null ? xmlDoc.SelectSingleNode("/user/name").InnerText : string.Empty;
                            userQuery.ScreenName = xmlDoc.SelectSingleNode("/user/screen_name") != null ? xmlDoc.SelectSingleNode("/user/screen_name").InnerText : string.Empty;
                            userQuery.Location = xmlDoc.SelectSingleNode("/user/location") != null ? xmlDoc.SelectSingleNode("/user/location").InnerText : string.Empty;
                            userQuery.Description = xmlDoc.SelectSingleNode("/user/description") != null ? xmlDoc.SelectSingleNode("/user/description").InnerText : string.Empty;
                            userQuery.ProfileImageURL = xmlDoc.SelectSingleNode("/user/profile_image_url") != null ? xmlDoc.SelectSingleNode("/user/profile_image_url").InnerText : string.Empty;
                            userQuery.URL = xmlDoc.SelectSingleNode("/user/url") != null ? xmlDoc.SelectSingleNode("/user/url").InnerText : string.Empty;
                            userQuery.Protected = xmlDoc.SelectSingleNode("/user/protected") != null ? xmlDoc.SelectSingleNode("/user/protected").InnerText : string.Empty;
                            userQuery.Followers = xmlDoc.SelectSingleNode("/user/followers_count") != null ? xmlDoc.SelectSingleNode("/user/followers_count").InnerText : string.Empty;
                            userQuery.ProfileBackgroundColor = xmlDoc.SelectSingleNode("/user/profile_background_color") != null ? xmlDoc.SelectSingleNode("/user/profile_background_color").InnerText : string.Empty;
                            userQuery.ProfileTextColor = xmlDoc.SelectSingleNode("/user/profile_text_color") != null ? xmlDoc.SelectSingleNode("/user/profile_text_color").InnerText : string.Empty;
                            userQuery.ProfileLinkColor = xmlDoc.SelectSingleNode("/user/profile_link_color") != null ? xmlDoc.SelectSingleNode("/user/profile_link_color").InnerText : string.Empty;
                            userQuery.ProfileSidebarFillColor = xmlDoc.SelectSingleNode("/user/profile_sidebar_fill_color") != null ? xmlDoc.SelectSingleNode("/user/profile_sidebar_fill_color").InnerText : string.Empty;
                            userQuery.ProfileSidebarBorderColor = xmlDoc.SelectSingleNode("/user/profile_sidebar_border_color") != null ? xmlDoc.SelectSingleNode("/user/profile_sidebar_border_color").InnerText : string.Empty;
                            userQuery.FriendsCount = xmlDoc.SelectSingleNode("/user/friends_count") != null ? xmlDoc.SelectSingleNode("/user/friends_count").InnerText : string.Empty;
                            userQuery.UtcOffset = xmlDoc.SelectSingleNode("/user/utc_offset") != null ? xmlDoc.SelectSingleNode("/user/utc_offset").InnerText : string.Empty;
                            userQuery.TimeZone = xmlDoc.SelectSingleNode("/user/time_zone") != null ? xmlDoc.SelectSingleNode("/user/time_zone").InnerText : string.Empty;
                            userQuery.ProfileBackgroundImageUrl = xmlDoc.SelectSingleNode("/user/profile_background_image_url") != null ? xmlDoc.SelectSingleNode("/user/profile_background_image_url").InnerText : string.Empty;
                            userQuery.ProfileBackgroundTile = xmlDoc.SelectSingleNode("/user/profile_background_tile") != null ? xmlDoc.SelectSingleNode("/user/profile_background_tile").InnerText : string.Empty;
                            userQuery.StatusesCount = xmlDoc.SelectSingleNode("/user/statuses_count") != null ? xmlDoc.SelectSingleNode("/user/statuses_count").InnerText : string.Empty;
                            userQuery.Notifications = xmlDoc.SelectSingleNode("/user/notifications") != null ? xmlDoc.SelectSingleNode("/user/notifications").InnerText : string.Empty;
                            userQuery.Following = xmlDoc.SelectSingleNode("/user/following") != null ? xmlDoc.SelectSingleNode("/user/following").InnerText : string.Empty;
                            userQuery.Verified = xmlDoc.SelectSingleNode("/user/verified") != null ? xmlDoc.SelectSingleNode("/user/verified").InnerText : string.Empty;
                            userQuery.StatusCreatedAt = xmlDoc.SelectSingleNode("/user/status/created_at") != null ? xmlDoc.SelectSingleNode("/user/status/created_at").InnerText : string.Empty;
                            userQuery.StatusID = xmlDoc.SelectSingleNode("/user/status/id") != null ? xmlDoc.SelectSingleNode("/user/status/id").InnerText : string.Empty;
                            userQuery.StatusText = xmlDoc.SelectSingleNode("/user/status/text") != null ? xmlDoc.SelectSingleNode("/user/status/text").InnerText : string.Empty;
                            userQuery.StatusSource = xmlDoc.SelectSingleNode("/user/status/source") != null ? xmlDoc.SelectSingleNode("/user/status/source").InnerText : string.Empty;
                            userQuery.StatusTruncated = xmlDoc.SelectSingleNode("/user/status/truncated") != null ? xmlDoc.SelectSingleNode("/user/status/truncated").InnerText : string.Empty;
                            userQuery.StatusInReplyToStatusID = xmlDoc.SelectSingleNode("/user/status/in_reply_to_status_id") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_status_id").InnerText : string.Empty;
                            userQuery.StatusInReplyToUserID = xmlDoc.SelectSingleNode("/user/status/in_reply_to_user_id") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_user_id").InnerText : string.Empty;
                            userQuery.StatusFavorited = xmlDoc.SelectSingleNode("/user/status/favorited") != null ? xmlDoc.SelectSingleNode("/user/status/favorited").InnerText : string.Empty;
                            userQuery.StatusInReplyToScreenName = xmlDoc.SelectSingleNode("/user/status/in_reply_to_screen_name") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_screen_name").InnerText : string.Empty;

                            break;
                        }
                    case DeliveryDevice.None:
                        {
                            HttpWebRequest messageRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/account/update_delivery_device.xml?device=none");
                            messageRequest.Method = "POST";
                            messageRequest.Credentials = new NetworkCredential(username, password);
                            messageRequest.ContentLength = 0;
                            messageRequest.ContentType = "application/x-www-form-urlencoded";
                            WebResponse response = messageRequest.GetResponse();
                            StreamReader sReader = new StreamReader(response.GetResponseStream());
                            responseStr = sReader.ReadToEnd();

                            XmlDocument xmlDoc = new XmlDocument();
                            xmlDoc.LoadXml(responseStr);

                            userQuery.ID = xmlDoc.SelectSingleNode("/user/id") != null ? xmlDoc.SelectSingleNode("/user/id").InnerText : string.Empty;
                            userQuery.Name = xmlDoc.SelectSingleNode("/user/name") != null ? xmlDoc.SelectSingleNode("/user/name").InnerText : string.Empty;
                            userQuery.ScreenName = xmlDoc.SelectSingleNode("/user/screen_name") != null ? xmlDoc.SelectSingleNode("/user/screen_name").InnerText : string.Empty;
                            userQuery.Location = xmlDoc.SelectSingleNode("/user/location") != null ? xmlDoc.SelectSingleNode("/user/location").InnerText : string.Empty;
                            userQuery.Description = xmlDoc.SelectSingleNode("/user/description") != null ? xmlDoc.SelectSingleNode("/user/description").InnerText : string.Empty;
                            userQuery.ProfileImageURL = xmlDoc.SelectSingleNode("/user/profile_image_url") != null ? xmlDoc.SelectSingleNode("/user/profile_image_url").InnerText : string.Empty;
                            userQuery.URL = xmlDoc.SelectSingleNode("/user/url") != null ? xmlDoc.SelectSingleNode("/user/url").InnerText : string.Empty;
                            userQuery.Protected = xmlDoc.SelectSingleNode("/user/protected") != null ? xmlDoc.SelectSingleNode("/user/protected").InnerText : string.Empty;
                            userQuery.Followers = xmlDoc.SelectSingleNode("/user/followers_count") != null ? xmlDoc.SelectSingleNode("/user/followers_count").InnerText : string.Empty;
                            userQuery.ProfileBackgroundColor = xmlDoc.SelectSingleNode("/user/profile_background_color") != null ? xmlDoc.SelectSingleNode("/user/profile_background_color").InnerText : string.Empty;
                            userQuery.ProfileTextColor = xmlDoc.SelectSingleNode("/user/profile_text_color") != null ? xmlDoc.SelectSingleNode("/user/profile_text_color").InnerText : string.Empty;
                            userQuery.ProfileLinkColor = xmlDoc.SelectSingleNode("/user/profile_link_color") != null ? xmlDoc.SelectSingleNode("/user/profile_link_color").InnerText : string.Empty;
                            userQuery.ProfileSidebarFillColor = xmlDoc.SelectSingleNode("/user/profile_sidebar_fill_color") != null ? xmlDoc.SelectSingleNode("/user/profile_sidebar_fill_color").InnerText : string.Empty;
                            userQuery.ProfileSidebarBorderColor = xmlDoc.SelectSingleNode("/user/profile_sidebar_border_color") != null ? xmlDoc.SelectSingleNode("/user/profile_sidebar_border_color").InnerText : string.Empty;
                            userQuery.FriendsCount = xmlDoc.SelectSingleNode("/user/friends_count") != null ? xmlDoc.SelectSingleNode("/user/friends_count").InnerText : string.Empty;
                            userQuery.UtcOffset = xmlDoc.SelectSingleNode("/user/utc_offset") != null ? xmlDoc.SelectSingleNode("/user/utc_offset").InnerText : string.Empty;
                            userQuery.TimeZone = xmlDoc.SelectSingleNode("/user/time_zone") != null ? xmlDoc.SelectSingleNode("/user/time_zone").InnerText : string.Empty;
                            userQuery.ProfileBackgroundImageUrl = xmlDoc.SelectSingleNode("/user/profile_background_image_url") != null ? xmlDoc.SelectSingleNode("/user/profile_background_image_url").InnerText : string.Empty;
                            userQuery.ProfileBackgroundTile = xmlDoc.SelectSingleNode("/user/profile_background_tile") != null ? xmlDoc.SelectSingleNode("/user/profile_background_tile").InnerText : string.Empty;
                            userQuery.StatusesCount = xmlDoc.SelectSingleNode("/user/statuses_count") != null ? xmlDoc.SelectSingleNode("/user/statuses_count").InnerText : string.Empty;
                            userQuery.Notifications = xmlDoc.SelectSingleNode("/user/notifications") != null ? xmlDoc.SelectSingleNode("/user/notifications").InnerText : string.Empty;
                            userQuery.Following = xmlDoc.SelectSingleNode("/user/following") != null ? xmlDoc.SelectSingleNode("/user/following").InnerText : string.Empty;
                            userQuery.Verified = xmlDoc.SelectSingleNode("/user/verified") != null ? xmlDoc.SelectSingleNode("/user/verified").InnerText : string.Empty;
                            userQuery.StatusCreatedAt = xmlDoc.SelectSingleNode("/user/status/created_at") != null ? xmlDoc.SelectSingleNode("/user/status/created_at").InnerText : string.Empty;
                            userQuery.StatusID = xmlDoc.SelectSingleNode("/user/status/id") != null ? xmlDoc.SelectSingleNode("/user/status/id").InnerText : string.Empty;
                            userQuery.StatusText = xmlDoc.SelectSingleNode("/user/status/text") != null ? xmlDoc.SelectSingleNode("/user/status/text").InnerText : string.Empty;
                            userQuery.StatusSource = xmlDoc.SelectSingleNode("/user/status/source") != null ? xmlDoc.SelectSingleNode("/user/status/source").InnerText : string.Empty;
                            userQuery.StatusTruncated = xmlDoc.SelectSingleNode("/user/status/truncated") != null ? xmlDoc.SelectSingleNode("/user/status/truncated").InnerText : string.Empty;
                            userQuery.StatusInReplyToStatusID = xmlDoc.SelectSingleNode("/user/status/in_reply_to_status_id") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_status_id").InnerText : string.Empty;
                            userQuery.StatusInReplyToUserID = xmlDoc.SelectSingleNode("/user/status/in_reply_to_user_id") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_user_id").InnerText : string.Empty;
                            userQuery.StatusFavorited = xmlDoc.SelectSingleNode("/user/status/favorited") != null ? xmlDoc.SelectSingleNode("/user/status/favorited").InnerText : string.Empty;
                            userQuery.StatusInReplyToScreenName = xmlDoc.SelectSingleNode("/user/status/in_reply_to_screen_name") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_screen_name").InnerText : string.Empty;

                            break;
                        }
                }
                return userQuery;
            }
            catch
            {
                return null;
            }
        }

        #endregion

        #region Account / Update Profile Colors

        /// <summary>
        /// Sets one or more hex values that control the color scheme of 
        /// the authenticating user's profile page on twitter.com.
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        /// <param name="color">HEX Color</param>
        public static string Account_UpdateProfileBackColor(string username, string password, string color)
        {
            try
            {
                string responseToReturn = string.Empty;

                byte[] colorBytes = System.Text.Encoding.ASCII.GetBytes("profile_background_color=" + color);
                string userTo64 = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password));


                HttpWebRequest updateRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/account/update_profile_colors.xml");
                updateRequest.Method = "POST";
                updateRequest.ServicePoint.Expect100Continue = false;

                updateRequest.Headers.Add("Authorization", "Basic " + userTo64);
                updateRequest.ContentType = "application/x-www-form-urlencoded";
                updateRequest.ContentLength = colorBytes.Length;

                Stream requestStream = updateRequest.GetRequestStream();
                requestStream.Write(colorBytes, 0, colorBytes.Length);
                requestStream.Close();

                try
                {
                    HttpWebResponse response;
                    response = (HttpWebResponse)updateRequest.GetResponse();
                    StreamReader responseStream = new StreamReader(response.GetResponseStream());

                    responseToReturn = responseStream.ReadToEnd();
                }
                catch (WebException ex)
                {
                    StreamReader str = new StreamReader(ex.Response.GetResponseStream());

                    responseToReturn = str.ReadToEnd();
                }



                return responseToReturn;
            }
            catch
            {
                return null;
            }
        }

        /// <summary>
        /// Sets one or more hex values that control the color scheme of 
        /// the authenticating user's profile page on twitter.com.
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        /// <param name="color">HEX Color</param>
        public static string Account_UpdateProfileTextColor(string username, string password, string color)
        {
            try
            {
                string responseToReturn = string.Empty;

                byte[] colorBytes = System.Text.Encoding.ASCII.GetBytes("profile_text_color=" + color);
                string userTo64 = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password));


                HttpWebRequest updateRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/account/update_profile_colors.xml");
                updateRequest.Method = "POST";
                updateRequest.ServicePoint.Expect100Continue = false;

                updateRequest.Headers.Add("Authorization", "Basic " + userTo64);
                updateRequest.ContentType = "application/x-www-form-urlencoded";
                updateRequest.ContentLength = colorBytes.Length;

                Stream requestStream = updateRequest.GetRequestStream();
                requestStream.Write(colorBytes, 0, colorBytes.Length);
                requestStream.Close();

                try
                {
                    HttpWebResponse response;
                    response = (HttpWebResponse)updateRequest.GetResponse();
                    StreamReader responseStream = new StreamReader(response.GetResponseStream());

                    responseToReturn = responseStream.ReadToEnd();
                }
                catch (WebException ex)
                {
                    StreamReader str = new StreamReader(ex.Response.GetResponseStream());

                    responseToReturn = str.ReadToEnd();
                }



                return responseToReturn;
            }
            catch
            {
                return null;
            }
        }

        /// <summary>
        /// Sets one or more hex values that control the color scheme of 
        /// the authenticating user's profile page on twitter.com.
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        /// <param name="color">HEX Color</param>
        public static string Account_UpdateProfileLinkColor(string username, string password, string color)
        {
            try
            {
                string responseToReturn = string.Empty;

                byte[] colorBytes = System.Text.Encoding.ASCII.GetBytes("profile_link_color=" + color);
                string userTo64 = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password));


                HttpWebRequest updateRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/account/update_profile_colors.xml");
                updateRequest.Method = "POST";
                updateRequest.ServicePoint.Expect100Continue = false;

                updateRequest.Headers.Add("Authorization", "Basic " + userTo64);
                updateRequest.ContentType = "application/x-www-form-urlencoded";
                updateRequest.ContentLength = colorBytes.Length;

                Stream requestStream = updateRequest.GetRequestStream();
                requestStream.Write(colorBytes, 0, colorBytes.Length);
                requestStream.Close();

                try
                {
                    HttpWebResponse response;
                    response = (HttpWebResponse)updateRequest.GetResponse();
                    StreamReader responseStream = new StreamReader(response.GetResponseStream());

                    responseToReturn = responseStream.ReadToEnd();
                }
                catch (WebException ex)
                {
                    StreamReader str = new StreamReader(ex.Response.GetResponseStream());

                    responseToReturn = str.ReadToEnd();
                }



                return responseToReturn;
            }
            catch
            {
                return null;
            }
        }

        /// <summary>
        /// Sets one or more hex values that control the color scheme of 
        /// the authenticating user's profile page on twitter.com.
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        /// <param name="color">HEX Color</param>
        public static string Account_UpdateProfileSidebarFillColor(string username, string password, string color)
        {
            try
            {
                string responseToReturn = string.Empty;

                byte[] colorBytes = System.Text.Encoding.ASCII.GetBytes("profile_sidebar_fill_color=" + color);
                string userTo64 = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password));


                HttpWebRequest updateRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/account/update_profile_colors.xml");
                updateRequest.Method = "POST";
                updateRequest.ServicePoint.Expect100Continue = false;

                updateRequest.Headers.Add("Authorization", "Basic " + userTo64);
                updateRequest.ContentType = "application/x-www-form-urlencoded";
                updateRequest.ContentLength = colorBytes.Length;

                Stream requestStream = updateRequest.GetRequestStream();
                requestStream.Write(colorBytes, 0, colorBytes.Length);
                requestStream.Close();

                try
                {
                    HttpWebResponse response;
                    response = (HttpWebResponse)updateRequest.GetResponse();
                    StreamReader responseStream = new StreamReader(response.GetResponseStream());

                    responseToReturn = responseStream.ReadToEnd();
                }
                catch (WebException ex)
                {
                    StreamReader str = new StreamReader(ex.Response.GetResponseStream());

                    responseToReturn = str.ReadToEnd();
                }



                return responseToReturn;
            }
            catch
            {
                return null;
            }
        }

        /// <summary>
        /// Sets one or more hex values that control the color scheme of 
        /// the authenticating user's profile page on twitter.com.
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        /// <param name="color">HEX Color</param>
        public static string Account_UpdateProfileSidebarBorderColor(string username, string password, string color)
        {
            try
            {
                string responseToReturn = string.Empty;

                byte[] colorBytes = System.Text.Encoding.ASCII.GetBytes("profile_sidebar_border_color=" + color);
                string userTo64 = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password));


                HttpWebRequest updateRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/account/update_profile_colors.xml");
                updateRequest.Method = "POST";
                updateRequest.ServicePoint.Expect100Continue = false;

                updateRequest.Headers.Add("Authorization", "Basic " + userTo64);
                updateRequest.ContentType = "application/x-www-form-urlencoded";
                updateRequest.ContentLength = colorBytes.Length;

                Stream requestStream = updateRequest.GetRequestStream();
                requestStream.Write(colorBytes, 0, colorBytes.Length);
                requestStream.Close();

                try
                {
                    HttpWebResponse response;
                    response = (HttpWebResponse)updateRequest.GetResponse();
                    StreamReader responseStream = new StreamReader(response.GetResponseStream());

                    responseToReturn = responseStream.ReadToEnd();
                }
                catch (WebException ex)
                {
                    StreamReader str = new StreamReader(ex.Response.GetResponseStream());

                    responseToReturn = str.ReadToEnd();
                }



                return responseToReturn;
            }
            catch
            {
                return null;
            }
        }
        #endregion

        #region Account / Update Profile Image

       
        public enum ImageExtension
        {
            JPEG,
            GIF,
            PNG
        }

        /// <summary>
        /// Updates the authenticating user's profile image. 
        /// Note that this method expects raw multipart data, not a URL to an image.
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        /// <param name="image">The byte array that contains the image.</param>
        /// <param name="extension">The image extension.</param>
        public static string Account_UpdateProfileImage(string username, string password, byte[] image, ImageExtension extension)
        {
            try
            {
                string s = string.Empty;

                System.Net.ServicePointManager.Expect100Continue = false;

                HttpWebRequest updateRequest = (HttpWebRequest)HttpWebRequest.Create(@"http://twitter.com/account/update_profile_image.xml");
                updateRequest.PreAuthenticate = true;
                updateRequest.AllowWriteStreamBuffering = true;

                string boundary = System.Guid.NewGuid().ToString();

                updateRequest.Credentials = new NetworkCredential(username, password);
                updateRequest.ContentType = String.Format("multipart/form-data;boundary={0}", boundary);
                updateRequest.Method = "POST";

                string header = "--" + boundary;
                string footer = "--" + boundary + "--";

                StringBuilder headers = new StringBuilder();

                headers.AppendLine(header);

                switch (extension)
                {
                    case ImageExtension.PNG:
                        {
                            headers.AppendLine(String.Format("Content-Disposition:form-data); name=\"image\"); filename=\"{0}\"", "image.png"));
                            headers.AppendLine("Content-Type: image/png");
                            break;
                        }
                    case ImageExtension.GIF:
                        {
                            headers.AppendLine(String.Format("Content-Disposition:form-data); name=\"image\"); filename=\"{0}\"", "image.gif"));
                            headers.AppendLine("Content-Type: image/gif");
                            break;
                        }
                    case ImageExtension.JPEG:
                        {
                            headers.AppendLine(String.Format("Content-Disposition:form-data); name=\"image\"); filename=\"{0}\"", "image.jpg"));
                            headers.AppendLine("Content-Type: image/jpeg");
                            break;
                        }
                }

                headers.AppendLine();
                headers.AppendLine(System.Text.Encoding.GetEncoding("iso-8859-1").GetString(image));
                headers.AppendLine(footer);

                byte[] contents = Encoding.GetEncoding("iso-8859-1").GetBytes(headers.ToString());

                updateRequest.ContentLength = contents.Length;

                using (Stream requestStream = updateRequest.GetRequestStream())
                {
                    requestStream.Write(contents, 0, contents.Length);
                    requestStream.Flush();
                    requestStream.Close();


                    using (WebResponse webResponse = updateRequest.GetResponse())
                    {
                        using (StreamReader responseReader = new StreamReader(webResponse.GetResponseStream()))
                        {
                            s = responseReader.ReadToEnd();
                        }
                    }
                }
                return s;
            }
            catch (Exception ex)
            {
                return ex.Message;
            }

        }

        #endregion

        #region Account / Update Profile Information
        public enum ProfileParam
        {
            Name,
            Email,
            URL,
            Location,
            Description
        }

        /// <summary>
        /// Sets values that users are able to set under the "Account" tab of their settings page.
        /// Only the parameters specified will be updated.
        /// </summary>
        /// <param name="username">Twitter account username.</param>
        /// <param name="password">Twitter account password.</param>
        /// <param name="param">Profile parameter to update.</param>
        /// <param name="paramValue">Parameter value.</param>

        public static User Account_UpdateProfile(string username, string password, ProfileParam param, string paramValue)
        {
            try
            {
                User userQuery = new User();
                string responseStr;

                HttpWebRequest messageRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/account/update_profile.xml");

                switch (param)
                {
                    case ProfileParam.Description:
                        {
                            messageRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/account/update_profile.xml?description=" + paramValue);
                            break;
                        }
                    case ProfileParam.Email:
                        {
                            messageRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/account/update_profile.xml?email=" + paramValue);
                            break;
                        }
                    case ProfileParam.Location:
                        {
                            messageRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/account/update_profile.xml?location=" + paramValue);
                            break;
                        }
                    case ProfileParam.Name:
                        {
                            messageRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/account/update_profile.xml?name=" + paramValue);
                            break;
                        }
                    case ProfileParam.URL:
                        {
                            messageRequest = (HttpWebRequest)WebRequest.Create("http://twitter.com/account/update_profile.xml?url=" + paramValue);
                            break;
                        }
                }
                messageRequest.Method = "POST";
                messageRequest.Credentials = new NetworkCredential(username, password);
                messageRequest.ContentLength = 0;
                messageRequest.ContentType = "application/x-www-form-urlencoded";
                WebResponse response = messageRequest.GetResponse();
                StreamReader sReader = new StreamReader(response.GetResponseStream());
                responseStr = sReader.ReadToEnd();

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(responseStr);

                userQuery.ID = xmlDoc.SelectSingleNode("/user/id") != null ? xmlDoc.SelectSingleNode("/user/id").InnerText : string.Empty;
                userQuery.Name = xmlDoc.SelectSingleNode("/user/name") != null ? xmlDoc.SelectSingleNode("/user/name").InnerText : string.Empty;
                userQuery.ScreenName = xmlDoc.SelectSingleNode("/user/screen_name") != null ? xmlDoc.SelectSingleNode("/user/screen_name").InnerText : string.Empty;
                userQuery.Location = xmlDoc.SelectSingleNode("/user/location") != null ? xmlDoc.SelectSingleNode("/user/location").InnerText : string.Empty;
                userQuery.Description = xmlDoc.SelectSingleNode("/user/description") != null ? xmlDoc.SelectSingleNode("/user/description").InnerText : string.Empty;
                userQuery.ProfileImageURL = xmlDoc.SelectSingleNode("/user/profile_image_url") != null ? xmlDoc.SelectSingleNode("/user/profile_image_url").InnerText : string.Empty;
                userQuery.URL = xmlDoc.SelectSingleNode("/user/url") != null ? xmlDoc.SelectSingleNode("/user/url").InnerText : string.Empty;
                userQuery.Protected = xmlDoc.SelectSingleNode("/user/protected") != null ? xmlDoc.SelectSingleNode("/user/protected").InnerText : string.Empty;
                userQuery.Followers = xmlDoc.SelectSingleNode("/user/followers_count") != null ? xmlDoc.SelectSingleNode("/user/followers_count").InnerText : string.Empty;
                userQuery.ProfileBackgroundColor = xmlDoc.SelectSingleNode("/user/profile_background_color") != null ? xmlDoc.SelectSingleNode("/user/profile_background_color").InnerText : string.Empty;
                userQuery.ProfileTextColor = xmlDoc.SelectSingleNode("/user/profile_text_color") != null ? xmlDoc.SelectSingleNode("/user/profile_text_color").InnerText : string.Empty;
                userQuery.ProfileLinkColor = xmlDoc.SelectSingleNode("/user/profile_link_color") != null ? xmlDoc.SelectSingleNode("/user/profile_link_color").InnerText : string.Empty;
                userQuery.ProfileSidebarFillColor = xmlDoc.SelectSingleNode("/user/profile_sidebar_fill_color") != null ? xmlDoc.SelectSingleNode("/user/profile_sidebar_fill_color").InnerText : string.Empty;
                userQuery.ProfileSidebarBorderColor = xmlDoc.SelectSingleNode("/user/profile_sidebar_border_color") != null ? xmlDoc.SelectSingleNode("/user/profile_sidebar_border_color").InnerText : string.Empty;
                userQuery.FriendsCount = xmlDoc.SelectSingleNode("/user/friends_count") != null ? xmlDoc.SelectSingleNode("/user/friends_count").InnerText : string.Empty;
                userQuery.UtcOffset = xmlDoc.SelectSingleNode("/user/utc_offset") != null ? xmlDoc.SelectSingleNode("/user/utc_offset").InnerText : string.Empty;
                userQuery.TimeZone = xmlDoc.SelectSingleNode("/user/time_zone") != null ? xmlDoc.SelectSingleNode("/user/time_zone").InnerText : string.Empty;
                userQuery.ProfileBackgroundImageUrl = xmlDoc.SelectSingleNode("/user/profile_background_image_url") != null ? xmlDoc.SelectSingleNode("/user/profile_background_image_url").InnerText : string.Empty;
                userQuery.ProfileBackgroundTile = xmlDoc.SelectSingleNode("/user/profile_background_tile") != null ? xmlDoc.SelectSingleNode("/user/profile_background_tile").InnerText : string.Empty;
                userQuery.StatusesCount = xmlDoc.SelectSingleNode("/user/statuses_count") != null ? xmlDoc.SelectSingleNode("/user/statuses_count").InnerText : string.Empty;
                userQuery.Notifications = xmlDoc.SelectSingleNode("/user/notifications") != null ? xmlDoc.SelectSingleNode("/user/notifications").InnerText : string.Empty;
                userQuery.Following = xmlDoc.SelectSingleNode("/user/following") != null ? xmlDoc.SelectSingleNode("/user/following").InnerText : string.Empty;
                userQuery.Verified = xmlDoc.SelectSingleNode("/user/verified") != null ? xmlDoc.SelectSingleNode("/user/verified").InnerText : string.Empty;
                userQuery.StatusCreatedAt = xmlDoc.SelectSingleNode("/user/status/created_at") != null ? xmlDoc.SelectSingleNode("/user/status/created_at").InnerText : string.Empty;
                userQuery.StatusID = xmlDoc.SelectSingleNode("/user/status/id") != null ? xmlDoc.SelectSingleNode("/user/status/id").InnerText : string.Empty;
                userQuery.StatusText = xmlDoc.SelectSingleNode("/user/status/text") != null ? xmlDoc.SelectSingleNode("/user/status/text").InnerText : string.Empty;
                userQuery.StatusSource = xmlDoc.SelectSingleNode("/user/status/source") != null ? xmlDoc.SelectSingleNode("/user/status/source").InnerText : string.Empty;
                userQuery.StatusTruncated = xmlDoc.SelectSingleNode("/user/status/truncated") != null ? xmlDoc.SelectSingleNode("/user/status/truncated").InnerText : string.Empty;
                userQuery.StatusInReplyToStatusID = xmlDoc.SelectSingleNode("/user/status/in_reply_to_status_id") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_status_id").InnerText : string.Empty;
                userQuery.StatusInReplyToUserID = xmlDoc.SelectSingleNode("/user/status/in_reply_to_user_id") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_user_id").InnerText : string.Empty;
                userQuery.StatusFavorited = xmlDoc.SelectSingleNode("/user/status/favorited") != null ? xmlDoc.SelectSingleNode("/user/status/favorited").InnerText : string.Empty;
                userQuery.StatusInReplyToScreenName = xmlDoc.SelectSingleNode("/user/status/in_reply_to_screen_name") != null ? xmlDoc.SelectSingleNode("/user/status/in_reply_to_screen_name").InnerText : string.Empty;

                return userQuery;
            }
            catch
            {
                return null;
            }
        }
        #endregion
    }
}
